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

fix(store): reactive warning

上级 43085e7a
<script lang="ts"> <script lang="uts">
import { state, setLifeCycleNum } from './store/index.uts' import { state, setLifeCycleNum } from '@/store/index.uts'
export default { export default {
onLaunch: function () { onLaunch: function () {
// 自动化测试 // 自动化测试
......
...@@ -4,17 +4,21 @@ ...@@ -4,17 +4,21 @@
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<text>点击按钮调用 App.uvue methods</text> <text>点击按钮调用 App.uvue methods</text>
<text class="margin-top:6px;">increasetLifeCycleNum 方法</text> <text class="margin-top:6px;">increasetLifeCycleNum 方法</text>
<button class="uni-common-mt" @click="_increasetLifeCycleNum">increase lifeCycleNum</button> <button class="uni-common-mt" @click="_increasetLifeCycleNum">
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text> <text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view> </view>
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts' import { State, state, setLifeCycleNum } from '@/store/index.uts'
export default { export default {
data() { data() {
return { return {
_state: state as State,
lifeCycleNum: 0, lifeCycleNum: 0,
} }
}, },
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
class Page { class Page {
constructor(public route : string) { constructor(public route : string) {
} }
} }
export default { export default {
data() { data() {
return { return {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
export default { export default {
data() { data() {
return { return {
......
...@@ -45,11 +45,13 @@ ...@@ -45,11 +45,13 @@
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts' import { State, state, setLifeCycleNum } from '@/store/index.uts'
export default { export default {
data() { data() {
return { return {
_state: state as State,
onLoadTime: 0, onLoadTime: 0,
onShowTime: 0, onShowTime: 0,
onReadyTime: 0, onReadyTime: 0,
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
import { state } from '@/store/index.uts' import { state } from '@/store/index.uts'
export default { export default {
data() { data() {
return { return {
......
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts' import { State, state, setLifeCycleNum } from '@/store/index.uts'
export default { export default {
data() { data() {
return { return {
_state: state as State,
isScrolled: false, isScrolled: false,
} }
}, },
......
<template> <template>
<view> <view>
<page-head title="setNavigationBarColor"></page-head> <page-head title="setNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn"> <button @tap="setNavigationBarColor1" class="uni-btn">
设置导航条背景绿色,标题白色 设置导航条背景绿色,标题白色
</button> </button>
<button @tap="setNavigationBarColor2" class="uni-btn"> <button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色 设置导航条背景红色,标题黑色
</button> </button>
</view> </view>
</view> </view>
</template> </template>
<script lang="ts"> <script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts' import { State, state, setLifeCycleNum } from '@/store/index.uts'
export default {
methods: { export default {
data() {
return {
_state: state as State
}
},
methods: {
setNavigationBarColor1() { setNavigationBarColor1() {
uni.setNavigationBarColor({ uni.setNavigationBarColor({
frontColor: '#ffffff', frontColor: '#ffffff',
...@@ -51,24 +57,24 @@ export default { ...@@ -51,24 +57,24 @@ export default {
setLifeCycleNum(state.lifeCycleNum + 1) setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
// 自动化测试 // 自动化测试
getLifeCycleNum(): number { getLifeCycleNum(): number {
return state.lifeCycleNum return state.lifeCycleNum
}, },
// 自动化测试 // 自动化测试
setLifeCycleNum(num: number) { setLifeCycleNum(num: number) {
setLifeCycleNum(num) setLifeCycleNum(num)
}, },
}, },
} }
</script> </script>
<style> <style>
.direction-row { .direction-row {
flex-direction: row; flex-direction: row;
} }
.label { .label {
width: 190px; width: 190px;
} }
</style> </style>
type State = { export type State = {
lifeCycleNum: number lifeCycleNum: number
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册