GithubHelp home page GithubHelp logo

Comments (6)

otakustay avatar otakustay commented on May 2, 2024

补充一下,实际实现这么做会导致元素追踪比较难,比如N层都是Component的嵌套的情况下,最后渲染出来的一个DOM到底是哪一层的el之类的会比较烦人,最好的方法可能就是把el这东西和组件树完全脱钩了,一个组件完全可以没有一个必须是DOM Element的el,而可以有一个是组件、元素、文本等任何东西的抽象上的Node

from san.

erik168 avatar erik168 commented on May 2, 2024

其实我们在决定“一个component的template必须包含一个element作为root”的时候就已经作出选择了,就是不支持这种。

react也是如此的,vue2也变成这样了

在我们决定这个之前,我的实现是外面自动包一层。编写是方便一点,但是生成后的结构依然存在冗余

from san.

otakustay avatar otakustay commented on May 2, 2024

我还以为当时我们说的是“一个component的template必须有且仅有一个root”,而没有说必须是element……

react实测是可以组件的root是另一个组件的,我在写这个issue的时候特地去试了……

from san.

erik168 avatar erik168 commented on May 2, 2024

你觉得写template: '<ui-list></ui-list>'的人是什么心态?

  1. 我这个组件内只有一个ui-list
  2. 我就是ui-list

from san.

otakustay avatar otakustay commented on May 2, 2024

不会有人写template: '',只会有人写template: '<ui-list></ui-list>

这个心态的问题我实际写的时候也思考了很久,我认为基于我们“所有组件只能有一个root”的原则,它的含义就是“我是XXX”

你写template: '<div><input></div>',其实意思就是“我是一个内部有input的div”,依此类推template: '<ui-list datasource="{{myStaticList}}"></ui-list>'的意思是“我是一个指定了数据源的ui-list

from san.

erik168 avatar erik168 commented on May 2, 2024

额。。。我上面template里的内容被过滤掉了,哈哈

from san.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.