在我的页面中,我有以下head body属性
export default{
head: {
bodyAttrs: {
class: 'parallax-visible'
}
},
methods:{
modifyHeadTags(){
//here change the body class
//eg set like this.head.bodyAttrs.class="newclass"
console.log("head is", this.head); //this is undefined
}
}
现在上面的函数记录了头是未定义的,我如何以编程方式修改这些头标签
所以在函数中,我希望做一些类似这样的事情
this.head.bodyAttrs.class = "new class" //this one
发布于 2018-08-12 19:28:22
this.$options
中提供了head
以及vueJs
中的components
、methods
和其他属性
您可以在方法函数内部使用this.$options.head
访问head。
所以你需要在函数内部做一些类似的事情,
this.$options.head.bodyAttrs.class="newclass" //make sure bodyAttrs is defined in head object
https://stackoverflow.com/questions/51808054
复制相似问题