New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.36新特性:ms-duplex 尝试保持原有数据的类型 #520
Comments
之前的一次更新“优化 ms-duplex,对于 checkbox,现在不强制对应一个数组,交由内部转换” <!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>测试用例</title>
</head>
<body ms-controller="xxx">
<div>
<input type="checkbox" ms-duplex="x" value="2">x:{{x}}
<input type="checkbox" ms-duplex-radio="x">x:{{x}}
</div>
<script src="avalon.js"></script>
<script>
var model = avalon.define({
$id: 'xxx',
x: 2
});
</script>
</body>
</html> |
之前的版本,还没有对checkbox进行类型转换,现在好了 <!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>测试用例</title>
<script src="avalon.js"></script>
</head>
<body ms-controller="test">
<div>
<input type="checkbox" ms-duplex="x" value="2">2
<input type="checkbox" ms-duplex="x" value="4">4
<button type="button" ms-click="change">
将x改成{{ x == 2 ? 4: 2}}
</button>
<input type="checkbox" ms-duplex-radio="x">x:{{x}}
</div>
<script>
var model = avalon.define({
$id: 'test',
x: 2,
change: function() {
model.x = model.x === 2 ? 4 : 2
}
});
model.$watch("x", function(a) {
console.log(a)
})
</script>
</body>
</html> |
上面的demo好像没有双向的概念在里面,只是验证了数据源变化,视图会跟着变化,但是点击切换checkbox没什么效果 @RubyLouvre |
有啊,你应该认真了解一下ms-duplex及其分支的各种用法 |
那这个对应的是原来那种写法?新的写法还不熟,可以说明一下 |
用法还是原来的啊 |
你可以试试这个demo,新版本没看出来效果 @RubyLouvre <!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>测试用例</title>
</head>
<body ms-controller="xxx">
<div>
新版本:
<input type="checkbox" ms-duplex="x" value="1">
<input type="checkbox" ms-duplex="x" value="false">x:{{x}}
<br>radio:
<input type="checkbox" ms-duplex-radio="y">y:{{y}}
<br>数组:
<input type="checkbox" ms-duplex="z" value="1">
<input type="checkbox" ms-duplex="z" value="false">z:{{z}}
</div>
<script src="avalon.mobile.js"></script>
<script>
var model = avalon.define({
$id: 'xxx',
x: 1,
y: true,
z: []
});
</script>
</body>
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: