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

暂不支持 sourceSlot+循环 #504

Open
cxtom opened this issue Jun 16, 2020 · 0 comments
Open

暂不支持 sourceSlot+循环 #504

cxtom opened this issue Jun 16, 2020 · 0 comments

Comments

@cxtom
Copy link
Contributor

cxtom commented Jun 16, 2020

初始化 sourceSlot 的时候没有支持循环的情况:https://github.com/baidu/san/blob/master/src/view/component.js#L340

比如下面的代码:

var Folder = san.defineComponent({
  template: '<div><div s-for="i in repeat" class="slot-wrapper repeat-{{i}}"><slot name="cc-{{i}}"/></div></div>',
  initData: function () {
    return {repeat: [1,2]}
  }
});

var MyComponent = san.defineComponent({
  components: {
    'x-folder': Folder
  },

  initData: function () {
    return {repeat: [1,2]}
  },

  template: ''
    + '<div>'
    + '<x-folder hidden="{{folderHidden}}"><b s-for="i in repeat" slot="cc-{{i}}">{{name}}</b></x-folder>'
    + '</div>'
});

这种写法的作用一般是为了给所有子节点的外层都套一层dom

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

No branches or pull requests

1 participant