当前位置:网站首页>Wechat applet change attribute value -setdata- bidirectional binding -model
Wechat applet change attribute value -setdata- bidirectional binding -model
2022-07-29 05:39:00 【Program ape runs forward】
How to change the properties of an array and object ?
1、 Change the value in the array
set up paraList:[{
txt:'123',chose:false},{
txt:'1234',chose:false}]
let choseChange = "paraList[" + index + "].chose"
_this.setData({
[choseChange]: true,
numList: numList
})
You can change the value of a specific subscript in the array
2、 Change the value in the object
userInfo: {
// User authentication information
sex: '',
name: '',
phone: '',
code: '',
sexTxt:' Please choose your gender ',
nameTxt:' Name cannot be empty ',
phoneTxt: ' Cell phone number cannot be empty ',
codeTxt: ' Get verification code ',
codeErrTxt:' Verification code cannot be empty '
},
let userSex = "userInfo.sex"
_this.setData({
[userSex]: '1'
})
Can be changed separately userInfo Medium sex value
(1) In non custom components
<input model:value="{
{ attribute }}" />
I won't support it data in . The way of writing path
Such as :<input model:value="{
{ a.b }}" />
(2) Custom components Components in
1、 Define the format of the passed in attribute
Component({
properties: {
myValue: String
}
})
2、 Used in components
<input model:value="{
{myValue}}" />
3、 Where this component is referenced
<custom-component model:my-value="{
{ attribute }}" /> my-value Can be any field , In the component, it should be written in the form of hump
https://blog.csdn.net/Shids_/article/details/125538656
边栏推荐
猜你喜欢
虚拟增强与现实第二篇 (我是一只火鸟)
Redirection and files
Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises
Cmu15-213 shell lab experiment record
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
uniapp之常用提示弹框
B - 识别浮点常量问题
[C language series] - a recursive topic
实现table某个单元格背景色设置
随机推荐
uniapp之常用提示弹框
shell基本操作(上)
基础爬虫实战案例之获取游戏商品数据
About local variables
Flask 报错 RuntimeError: The session is unavailable because no secret key was set.
uniapp页面标题显示效果
Talking about Servlet
shell基本操作(下)
Integer overflow and printing
Cmu15-213 shell lab experiment record
抽象类与接口
用sql-client.sh生成的job在cancle过后 如何实现断点续传?
数据库操作 Day 6
js深拷贝-笔记
uniapp组件之tab选项卡滑动切换
Detailed explanation of exit interrupt
Qtcreator+cmake compiler settings
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises
微信小程序更改属性值-setData-双向绑定-model
Clickhouse learning (IV) SQL operation