Promise
Promise.reject 失败的回调
https://blog.csdn.net/qq_37939251/article/details/93650542
function getStr1() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('我');
}, 1000);
});
}
function getStr2() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('爱');
}, 1000);
});
}
function getStr3() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('米');
}, 1000);
});
}
function getStr4() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('饭');
}, 1000);
});
}
getStr1().then(function (data) {
console.log(data);
return getStr2();
}).then(function (data) {
console.log(data);
return getStr3();
}).then(function (data) {
console.log(data);
return getStr4();
}).then(function (data) {
console.log(data);
})
prototype
Vue.prototype.$appName = ‘My App’
https://cn.vuejs.org/v2/cookbook/adding-instance-properties.html
main.js
Vue.prototype.msgSuccess = function(msg) {
this.$message({
showClose: true,
message: msg,
type: "success"
});
}
demo.vue
this.msgSuccess("删除成功");