Survive by day and develop by night.
talk is cheap, show me the code,make a better result.
目录
vue import 默认导入当前的资源文件,
概述
vue是一种事件驱动式架构
需求:
vue 如何监听select 事件呢?
设计思路
实现思路分析
1.URL管理
<template>
<div @click="stringClick">{{msg}}</div>
</template>
<script>
export default {
name: "jianting",
data() {
return {
msg: "1223"
};
},
watch: {
msg: function(newVal, oldVal) {
// TO DO
console.log("newVal:", newVal);
console.log("oldVal:", oldVal);
}
},
methods: {
stringClick() {
this.msg = Math.random() * 100;
}
}
};
</script>
watch: {
$route: {
handler: function(val, oldVal) {
console.log(val);
},
// 深度观察监听
deep: true,
immediate: true
}
}
拓展实现
这里参考:github:简单实现上述流程:
入门级实现:
: 部分源码实现.
: 源码实现
性能参数测试:
无
参考资料和推荐阅读
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~