Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] Vue.observable你有了解过吗?说说看 #507

Open
haizhilin2013 opened this issue Jun 25, 2019 · 4 comments
Open

[vue] Vue.observable你有了解过吗?说说看 #507

haizhilin2013 opened this issue Jun 25, 2019 · 4 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] Vue.observable你有了解过吗?说说看

@haizhilin2013 haizhilin2013 added the vue vue label Jun 25, 2019
@dengBox
Copy link

dengBox commented Jun 28, 2019

类轻量级vuex,用作状态管理。

@girlfighting
Copy link

vue2.6发布一个新的API,可以处理一些简单的跨组件共享数据状态的问题。

@HeMin0919
Copy link

//store.js
import Vue from 'vue';

export let store =Vue.observable({count:0,name:'张三'});
export let mutations={
setCount(count){
store.count=count;
},
setName(name){
store.name=name;
}
}

@censek
Copy link

censek commented Oct 12, 2019

让一个对象可响应。Vue 内部会用它来处理 data 函数返回的对象。

返回的对象可以直接用于渲染函数和计算属性内,并且会在发生改变时触发相应的更新;也可以作为最小化的跨组件状态存储器。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

5 participants