Skip to content
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

template配置支持函数 #179

Open
leeluolee opened this issue May 1, 2017 · 1 comment
Open

template配置支持函数 #179

leeluolee opened this issue May 1, 2017 · 1 comment

Comments

@leeluolee
Copy link
Member

leeluolee commented May 1, 2017

template支持函数,它将在config之后被调用,可以根据data来动态生成模板。

const App = Regular.extend({
  template(data){
  return (`
    <Menu>
      <Menu.SubMenu>
        ${data.items.map(function(item){
          return `<Menu.Item>${item.title}</Menu.Item>`
        })}
      </Menu.SubMenu>
    </Menu>
  `)
  }  }
})

它解决两个问题,

  1. 规避一些冗余的bingding
  2. 组合式的组件封装也可以方便的用数据配置来进行驱动的,算是能得到阉割版的JSX的能力(不过只生成一次,后续流程仍然是binding)
@rainfore
Copy link
Contributor

rainfore commented May 1, 2017

吊爆了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants