console
var Main = {
data() {
return {
x: 2,
y: 3
}
},
computed:{
sum1(){
return this.x + this.y
}
},
asyncComputed: {
sum () {
const total = this.x + this.y
return new Promise(resolve =>
setTimeout(() => resolve(total), 1000)
)
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
/*new Vue({
el: '#app',
data() {
return {
x: 2,
y: 3
}
},
computed:{
sum1(){
return this.x + this.y
}
},
asyncComputed: {
sum () {
const total = this.x + this.y
return new Promise(resolve =>
setTimeout(() => resolve(total), 1000)
)
}
}
});
*/
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@1.2.6/lib/index.js"></script>
<script src="https://unpkg.com/vue-async-computed"></script>
<div id="app">
<template>
asyncComputed:{{sum}}
<br>
Computed:{{sum1}}
</template>
</div>
@import url("//unpkg.com/element-ui/lib/theme-default/index.css");