我'm currently rendering all the html server-side and I' m试图让vue使用这个html作为 $el 用于以下两个组件 . 据我所知lifecycle diagram,这应该有效 .
有一个父Vue实例(绑定到 #main )并包含一个子组件(通过html中的 元素) .
现在我收到以下错误消息:
[Vue warn]: v-on:click="gotoSlide" expects a function value, got undefined
即使数据已明确定义, v-text 指令也不起作用 .
因此,问题似乎是,父实例已经将子组件中的所有指令编译为它自己的(例如,子组件中的 v-text 已经由父组件编译,在孩子初始化之前似乎) .
有没有办法防止这种情况发生,所以自定义子标记 中的指令只能由子元素编译?
Vue.component(`mod-sidebar`, {
ready: function() {
// initialize slider
},
data: function() {
return {
name: 'slider',
};
},
methods: {
gotoSlide: function(event) {
return false;
},
},
replace: false
});
new Vue({
el: '#main'
});