这次给大家带来的是vue.js 里如何做到父向子组件传参,这篇文章就给大家好好分析一下。
1.新建componentA.vue组件,代码如下:
const STORAGE_KEY = 'todos-vue.js'
export default{
fetch(){
return JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '[]')
},
save(items){
window.localStorage.setItem(STORAGE_KEY,JSON.stringify(items));
}
}App.vue代码如下:
- {{item.label}}
componentA.vue代码如下:
<{{msg}}
{{msgfromfather}}
立即学习“前端免费学习笔记(深入)”;
相信看了以上介绍你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
相关阅读:










