36avalon - 自定义标签

简介: 36avalon - 自定义标签

以ms-开头的自定义标签, 我们需要用avalon.component方法定义它,然后在里面使用ms-widget指令 为它添加更多行为.

avalon.component方法有两个参数,第一个标签名,必须以ms-开头;第二个是配置对象.

配置对象里也有4个配置项

  1. template,自定义标签的outerHTML,它必须是用一个普通的HTML元素节点包起来,里面可以使用ms-*等指令
  2. defaults,用来定义这个组件的VM有什么属性与方法
  3. soleSlot,表示自定义标签的innerHTML为一个默认的插入点 (或可理解为定义标签的innerHTML为当前组件某个属性的属性值) ,可选
  4. getTemplate, 用来修改template, 依次传入vm与template, 返回新的模板. 可选
avalon.component('ms-pager', {
      template: '<div><input type="text" ms-duplex-number="@num"/><button type="button" ms-on-click="@onPlus">+++</button></div>',
      defaults: {
          num: 1,
          onPlus: function () {
              this.num++;
          }
      },
      getTemplate: function(vm, template){
         return template.replace('ms-on-click','ms-on-mousenter')
      }
  });
目录
相关文章
|
5月前
|
搜索推荐 BI 开发者
sap.ui.comp.smarttable.SmartTable 组件 beforeRebindTable 事件的用法
sap.ui.comp.smarttable.SmartTable 组件 beforeRebindTable 事件的用法
|
12月前
|
JavaScript 算法 前端开发
02avalon - avalon入门案例
02avalon - avalon入门案例
35 0
|
12月前
|
算法
sap.ui.comp.smarttable.SmartTable 一些属性的用法阐述
sap.ui.comp.smarttable.SmartTable 一些属性的用法阐述
|
12月前
|
XML Java 数据格式
自定义标签
自定义标签
|
12月前
|
移动开发 前端开发 JavaScript
01avalon - avalon简介
01avalon - avalon简介
52 0
|
12月前
|
Java 程序员 开发者
自定义标签-下
自定义标签-下
35 0
|
Java 数据库
自定义标签的详细使用讲解【下】
自定义标签的详细使用讲解【下】
32 0
|
XML 设计模式 Java
自定义标签的详细使用讲解【上】(一)
自定义标签的详细使用讲解【上】
122 0
自定义标签的详细使用讲解【上】(二)
自定义标签的详细使用讲解【上】(二)
36 0
|
JavaScript
SAP Spartacus Popover Directive 构造函数的用途分析
SAP Spartacus Popover Directive 构造函数的用途分析
SAP Spartacus Popover Directive 构造函数的用途分析