Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

小程序怎么判断文字条件

最近做天气的小程序,要根据字段等于 晴 阴 小雨 大雨等显示不同图标,请问怎么条件判断

<text wx:if="{{after_tomorrow_cond_txt_d == "阴"}}" class="iconfont icon-dayu"></text>
...
...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

做一个字典表

const dict = [
 {key: "sun", title: "晴", path: "./sun.png"}
]

fotmatWeather(key){
    return dict.filter( item => item.key === key );
}

大约这样吧,有字典总是比较方便的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...