query.select('#alias-label').setStyle 这一句出错。
data: {
value: "李大伟"
},
lifetimes: {
ready: function() {
if(this.data.value.length > 0) {
var query = this.createSelectorQuery();
query.select('#alias-label').setStyle({ //此行报错
bottom: '20px'
});
console.log(query.select('#alias-label'));
}
}
},
<view class="wrapper">
<mp-icon icon="me" color="#287dfc" size="{{20}} "></mp-icon>
<view class="input-data">
<input class="input" type="text" model:value="{{value}}" bindfocus="{{wxs.onFoucs}}"/>
<view class="underline"></view>
<label class="label" id="alias-label">姓名</label>
</view>
</view>
<view class="wrapper">
<mp-icon icon="me" color="#287dfc" size="{{20}} "></mp-icon>
<view class="input-data">
<input class="input" type="text" model:value="{{value}}" bindfocus="{{wxs.onFoucs}}"/>
<view class="underline"></view>
<label class="label" id="alias-label">姓名</label>
</view>
</view>
最好不要这样,代码太难看了,小程序是数据驱动的思想,考虑动态绑定class来实现吧,https://developers.weixin.qq.com/miniprogram/dev/reference/wxml/data.html
你确定获取的节点对象有 setStyle 这个方法吗?
看看这个问题是否有帮助
https://developers.weixin.qq.com/community/develop/doc/000aa0f17a8af0e02d7c0ca5e56800