判断input取值是否为空?
wxs判断wxml中input组件传来的值是否为空应该怎么写呢?感谢大神指点!!!
//wxml
<input bindblur=“getSearchContent” placeholder="{{searcharea}}" focus="{{autofocus}}" ></input>
<button bindtap=‘saveData’>搜索</button>
//wxs
console.log(this.data.save_data)
if (this.data.save_data == ‘’) {
wx.showModal({
title: ‘提示’,
content: ‘输入不能为空’,
success: function(res) {
if (res.confirm) {
console.log(‘用户点击确定’)
}
}
})
}
saveExprs(this.data.save_data)
//获取缓存数据
var exprs = wx.getStorageSync(“save_array”) || []
this.setData({
arry_data: exprs
})
}