【发布时间】:2018-04-15 16:22:32
【问题描述】:
我正在使用 Firefox 56,并将 dom.moduleScripts.enabled 设置为 true。这让我可以使用原生 ES6 模块。
我有一个 vue2 组件,它定义了一个方法:
import StorageZonesAjaxMethods from '../../ajax/storage-zones.js';
....
methods: {
updateList()
{
//console.log(StorageZonesAjaxMethods);
StorageZonesAjaxMethods.getList();//function(response) { this.list = response.data.payload;});
},
},
具有方法的类在哪里:
export default new class StorageZonesAjaxMethods {
static getItem(id, then)
{
axios.get(`${Config.apiBaseUrl}/storage-zones/${id}`)
.then(response => then);
}
static getList(then)
{
alert('in get list');
axios.get(`${Config.apiBaseUrl}/storage-zones`)
.then(response => then);
}
我在 firefx 中收到错误 "TypeError: (intermediate value).getList is not a function",但 console.log 显示它是,但由于某种原因它在构造函数中。怎么回事?
【问题讨论】:
标签: javascript module ecmascript-6 vue.js