提交 bb1ee2eb 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

docs(uni-app x): plugins and globalData

上级 e95b31f7
......@@ -269,6 +269,50 @@ request({url: 'https://www.example.com/request'} as RequestOptions)
![](../static/go-to-definition.png)
## 插件
- uni-app x 暂不支持 i18n、Vuex、Pinia 等插件。
## 全局变量
可通过一个专用模块组织和管理全局变量,例如:
```ts
// store/index.uts
export type State = {
globalNum: number
}
export const state = reactive({ globalNum: 0 } as State)
export const setGlobalNum = (num: number) => {
state.globalNum = num
}
```
```ts
// pages/index/index.uvue
<template>
<text @click="plus">{{ globalNum }}</text>
</template>
<script>
import { state, setGlobalNum } from '@/store/index.uts'
export default {
computed: {
globalNum(): number {
return state.globalNum
}
},
methods: {
plus(){
setGlobalNum(state.globalNum + 1)
}
}
}
</script>
```
## uts不支持js的一些功能和特性
- 不支持undefined。任何变量被定义后,都需要赋值
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册