computed 属性第一次会返回 null
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start by reproducing the reported computed setup with the TypeScript example and inspect when the computed state value is initialized. Confirm that the first value is a string rather than null and that the component warning no longer occurs.
Written by the indexing model from the issue text.
Description
我按照如下方式使用 computed,但是第一次 state 会返回 null,导致我的组件警告提示,说传入了一个 null,但是需要 string
data: {
isConnected: true,
},
computed: {
text({ isConnected }) {
return isConnected ? "网络正常" : "网络异常";
},
state({ isConnected }) {
return isConnected ? "success" : "error";
},
},
lifetimes: {
attached() {
wx.onNetworkStatusChange((res) => {
this.setData({
isConnected: res.isConnected,
});
});
},
},
- Dominant language
- TypeScript
- Stars
- 696
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wechat-miniprogram/computed
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
wechat-miniprogram/computed#111 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
wechat-miniprogram/computed#106 · 2 comments ·
-
wechat-miniprogram/computed#103 · 1 assignee ·
-
behavior方式引用不能正常显示 Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
wechat-miniprogram/computed#100 ·
-
如何像vue一样传参呢 Openquestion
Difficulty 5/5 Over a week Newbie friendliness 15/100
wechat-miniprogram/computed#92 · 1 comment ·
All issues in wechat-miniprogram/computed
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·