this.$nextTick(() => {
})
data() {
return {
info: Object
}
},
watch: {
info: {
handler(val) {
console.log(val)
},
deep: true
}
}
data() {
return {
info: {
name: ''
}
}
},
watch: {
'info.name': (val) => {
console.log(val)
}
}
data() {
return {
isShow: false
}
},
beforeRouteLeave(to, from, next) {
if (isShow) {
next() // 继续执行
}
}
5.APP中点APP自带返回按钮时不关闭页面,而是路由回退
// app.vue
created() {
history.pushState(null, null, document.URL)
window.addEventListener('popstate', () => {
// history.pushState(null, null, document.URL)
})
}
data() {
return {
test: 0
}
},
mounted() {
this.add()
},
methods: {
add() {
var that = this
function test() {
console.log('test')
that.test ++
}
test()
}
}
mounted: function () {
//此方法绑定到window下面,提供给外部调用
window['showAdd'] = () => {
this.showAdd()
}
}
// 外部调用
window.showAdd()
this.$set(object, key, value)
this.$set(arr, index, newValue)