Vuejs2 使用vue时,标题将添加到事件页面上
我在vuejs应用程序中添加了头部设置 它的工作原理与我预期的不同。 当我打开主页时,我的标题是:“主页标题” 但当我打开事件页面时,我的标题是:“事件标题|主页标题” 我在事件页面上定义头部:Vuejs2 使用vue时,标题将添加到事件页面上,vuejs2,Vuejs2,我在vuejs应用程序中添加了头部设置 它的工作原理与我预期的不同。 当我打开主页时,我的标题是:“主页标题” 但当我打开事件页面时,我的标题是:“事件标题|主页标题” 我在事件页面上定义头部: head: { title: function () { return { inner: “events title", id: 'app_head', } }, meta: function () { r
head: {
title: function () {
return {
inner: “events title", id: 'app_head',
}
},
meta: function () {
return [
{ name: 'description', content: 'Events description ' }
]
},
link: [
{ rel: 'canonical', href: '/', id: 'canonical' },
],
},
看起来标题添加在事件页面上,我不需要这个。
我怎样才能修好它
修改的块:
我在源文件中找到了一个可能的决定
/node_modules/vue-head/vue-head.js
要设置空的初始值,请执行以下操作:
},
var opt = {
complement: '',
separator: ''
}
我看不到设置默认值的任何可能性,也不清楚为什么不应用我的设置。
我的网页有:
import VueHead from 'vue-head' // https://github.com/ktquez/vue-head
Vue.use(VueHead)
export default {
name: 'eventsTimelinePage',
mixins: [appMixin],
components: {},
data() {
return {
site_name:'!!', // I need to set to head these values
site_heading:'??',
site_description:'TTT',
}
}, // data () {
head: {
title: function () {
return { // Use page values for head
inner: 'Events of ' + this.site_name, id: 'app_head',
complement: '', // THAT IS NOT APPLIED
separator: '', // THAT IS NOT APPLIED
}
},
meta: function () {
return [
{
name: 'description',
content: 'Events of '+ this.site_name+' : '+ this.site_description,
id: 'description'
}
]
},
link: [
{ rel: 'canonical', href: '/', id: 'canonical' },
],
}, // head: {
created() {
}, // created() {
mounted() {
this.setAppTitle('Events', 'Events', bus)
retrieveAppDictionaries('eventsTimelinePage', ['events_per_page', 'site_name', 'site_heading', 'site_description']) // I read the data from db
bus.$on('appDictionariesRetrieved', (data) => {
if (data.request_key === 'eventsTimelinePage') {
this.events_per_page = data.events_per_page
this.site_name = data.site_name // ASSIGN VALUES FROM DB
this.site_heading = data.site_heading
this.site_description = data.site_description
this.$emit('updateHead') // REFRESH HEAD PROPS
}
})
this.loadEventsTimeline()
}, // mounted() {
谢谢 如果您查看他们的文档,就会看到一个“自定义标题”部分。在那里,他们谈到“分隔符”和“补码”有默认值——听起来你需要将它们设置为空字符串以消除它们。如果在文件/public/index.html中清除标记“”的内容,看起来部分有效。但不管怎么说,我得到了像“主页标题”这样的标题。我在所有页面上都设置了分隔符:“”,但看起来分隔符仍然有“|”值…请查看修改后的块您是否尝试在字符串中使用空格来覆盖默认值-可能它们完全忽略空字符串?请给出如何覆盖默认值的示例?