怎么在vue.extend 构造器中引用外部js 方法,就是 import {getAppFormList} from 'xxxx.js', 现在只能在main 中编写全局方法才可以调用到,见下方代码,button 点击时间无法调用外部 getAppFormList方法
// 创建构造器
var Profile = Vue.extend({
template: '<button @click="onLoadUserData">加载明细</button><p>{{firstName}} {{lastName}} aka {{alias}}</p>',
data: function () {
return {
id:1,
firstName: 'Walter',
lastName: 'White',
alias: 'Heisenberg'
}
}, methods: {
onLoadUserData() {
if (this.id > 0)
getAppFormList(this.id).then(res => {
const rv = res.data;
this.listData = rv.data.records;
});
}
})
// 创建 Profile 实例,并挂载到一个元素上。
new Profile().$mount('#mount-point')