我正在尝试搜索如何将Bluebird.js与vue.js一起使用但未找到任何内容的示例。
我在main.js中尝试这个:
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Promise from 'bluebird'; //<=== HERE
import Vue from 'vue';
import App from './App';
import router from './router';
Vue.config.productionTip = false;
Vue.use(Promise); //<=== HERE
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
});
答案 0 :(得分:0)
您无需做任何事情。
只要将Bluebird导入文件,就可以在Vue实例中使用它。
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Promise from 'bluebird'; //<=== HERE
import Vue from 'vue';
import App from './App';
import router from './router';
Vue.config.productionTip = false;
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
created: function() {
// access Promise inside of vue instance e.g. var p1 = new Promise...
}
});