1
我想擴展方法。示例:VueJS擴展方法和數據
Vue.extend({
data: function() {
return {
fetcData: 'Test',
}
},
methods: function(){
return {
modal: function(){ alert('Modal') },
}
}
});
Vue.extend({
....
});
我使用多個擴展。
// VueJS Instance
new Vue({
el: 'html',
data: {
effect: true
},
methods: {
xhrGet: function() {
alert(this.fetcData); // Undefined
this.modal(); // Undefined
},
xhrPost: function (event) {
alert('xhrPost')
}
}
});
錯誤代碼: this.fetchData未定義。 this.modal不是函數
'extend'用於創建組件。從你的代碼我沒有看到任何組件。 – highFlyingDodo