Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_24279267
unidocs-zh
提交
587a8e20
U
unidocs-zh
项目概览
qq_24279267
/
unidocs-zh
与 Fork 源项目一致
Fork自
DCloud / unidocs-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
587a8e20
编写于
9月 16, 2021
作者:
study夏羽
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs:vue3文档删除已翻译部分
上级
6ce0f880
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
253 addition
and
4498 deletion
+253
-4498
docs/vue-vuex.md
docs/vue-vuex.md
+0
-146
docs/vue3-api.md
docs/vue3-api.md
+2
-375
docs/vue3-basics.md
docs/vue3-basics.md
+126
-1576
docs/vue3-components.md
docs/vue3-components.md
+42
-1449
docs/vue3-vuex.md
docs/vue3-vuex.md
+83
-952
未找到文件。
docs/vue-vuex.md
浏览文件 @
587a8e20
...
...
@@ -181,28 +181,6 @@ app.$mount()
```
html
<!-- 页面路径:pages/index/index.vue -->
<template>
<view>
<view>
用户名:{{username}}
</view>
<view>
年龄:{{age}}
</view>
</view>
</template>
<script>
import
{
mapState
}
from
'
vuex
'
//引入mapState
export
default
{
data
()
{
return
{}
},
computed
:
mapState
({
// 从state中拿到数据 箭头函数可使代码更简练
username
:
state
=>
state
.
username
,
age
:
state
=>
state
.
age
,
})
}
</script>
```
...
...
@@ -218,37 +196,6 @@ app.$mount()
在
`uni-app`
项目根目录下,
`store`
目录
`index.js`
文件下:
```
js
<!--
页面路径
:
store
/
index
.
js
-->
import
Vue
from
'
vue
'
import
Vuex
from
'
vuex
'
Vue
.
use
(
Vuex
);
const
store
=
new
Vuex
.
Store
({
state
:
{
todos
:
[{
id
:
1
,
text
:
'
我是内容一
'
,
done
:
true
},
{
id
:
2
,
text
:
'
我是内容二
'
,
done
:
false
}
]
},
getters
:
{
doneTodos
:
state
=>
{
return
state
.
todos
.
filter
(
todo
=>
todo
.
done
)
}
}
})
export
default
store
```
...
...
@@ -335,51 +282,6 @@ export default store
-
在
`mutation`
传参(载荷)可以传递一个参数。
```
js
<!--
页面路径
:
store
/
index
.
js
-->
import
Vue
from
'
vue
'
import
Vuex
from
'
vuex
'
Vue
.
use
(
Vuex
);
const
store
=
new
Vuex
.
Store
({
state
:
{
count
:
1
},
mutations
:
{
add
(
state
,
n
)
{
state
.
count
+=
n
}
}
})
export
default
store
```
```
html
<!-- 页面路径:pages/index/index.vue -->
<template>
<view>
<view>
数量:{{count }}
</view>
<button
@
click=
"addCount"
>
增加
</button>
</view>
</template>
<script>
import
store
from
'
@/store/index.js
'
export
default
{
computed
:
{
count
()
{
return
this
.
$store
.
state
.
count
}
},
methods
:
{
addCount
()
{
store
.
commit
(
'
add
'
,
5
)
//每次累加 5
}
}
}
</script>
```
-
在
`mutation`
传参(载荷)可以也可以传递一个对象。让我们修改上面累加器的例子:
...
...
@@ -476,43 +378,12 @@ export default store
```
```
js
<!--
页面路径
:
store
/
index
.
js
-->
import
Vue
from
'
vue
'
import
Vuex
from
'
vuex
'
Vue
.
use
(
Vuex
);
const
store
=
new
Vuex
.
Store
({
state
:
{
count
:
1
},
mutations
:
{
add
(
state
)
{
// 变更状态
state
.
count
+=
2
}
}
})
export
default
store
```
我们要通过提交
`mutation`
的方式来改变状态数据,是因为我们想要更明确地追踪到状态的变化。如果是类似下面这样异步的话:
```
js
mutations
:
{
someMutation
(
state
)
{
api
.
callAsyncMethod
(()
=>
{
state
.
count
++
})
}
}
```
我们就不知道什么时候状态会发生改变,所以也就无法追踪了,这与
`mutation`
的设计初心相悖,所以强制规定它必须是同步函数。
...
...
@@ -570,26 +441,9 @@ export default store
-
`mapActions`
也支持传入参数(载荷):
```
js
methods
:
{
...
mapActions
([
'
addCountAction
'
// 将 `this.addCountAction(amount)` 映射为
//`this.$store.dispatch('addCountAction', amount)`
]),
}
```
-
`mapActions`
也支持传递一个对象:
```
js
methods
:
{
...
mapActions
({
addCount
:
'
addCountAction
'
,
// 将 `this.addCount()` 映射为 `this.$store.dispatch('addCountAction')`
})
}
```
...
...
docs/vue3-api.md
浏览文件 @
587a8e20
此差异已折叠。
点击以展开。
docs/vue3-basics.md
浏览文件 @
587a8e20
此差异已折叠。
点击以展开。
docs/vue3-components.md
浏览文件 @
587a8e20
此差异已折叠。
点击以展开。
docs/vue3-vuex.md
浏览文件 @
587a8e20
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录