<!DOCTYPE html> <html> <head> <title>项目</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<style>
.ms-controller{
visibility: hidden; /*防止出现{{x}}等插值表达式*/
}
</style>
</head> <body> <div ms-controller="indexController" class="ms-controller"> <p>-----------------------变量------------------------------</p> <div> <span>{{@x}}</span> </div> <p>-----------------------集合------------------------------</p> <ul><li ms-attr="{myAttr:el.a}" ms ms-for="el in @list" onclick="doClick(this)">{{el.a}}</li></ul> <!--自定义属性ms-attr--> </div> <script src="avalon2.js"></script> <script> var vm = avalon.define({ $id: "indexController", x: 100, list: [{ "a": "aa" }, { "a": "aa" }, { "a": "aa" }] });
function doClick(liObj)
{ alert(liObj.attributes["myAttr"].value);}
setTimeout(function () { vm.x = 19;},3000);
</script> </body> </html>
img图片src
<img ms-for="el in @issueDetailInfo.ImgList" ms-attr="{src:'../../../'+el}" data-preview-src="" data-preview-group="1" />
<div ms-if="el.type==0">if内容</div>
ms-click调用方法参数插值:
<ul><li ms-attr="{myAttr:el.a}" ms-for="el in @list" ms-on-click="@myClick(el.a)">{{el.a}}</li></ul> <!--ms-click 方法参数插值-->
var vm = avalon.define({
$id: "indexController",
x: 100,
list: [{ "a": "aa" }, { "a": "aa" }, { "a": "aa" }],
myClick: function (str) {
alert(str);
}
});
From:http://www.cnblogs.com/xuejianxiyang/p/6434402.html