-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Raise Error when template contains interpolation string outside of root node. #4789
Comments
Thanks for using Vue! If I have read correct, @simonmurdock is proposing that Vue should allow multiple nodes( e.g. text node + element node) in component root, is this right? To my best knowledge, I'm afraid this is probably out of Vue2.0's scope. Since the code base has a strong assumption that component root has a single node. Supporting text node outside root node would not only require a total rewrite but also introduce calamitous breaking changes. |
@HerringtonDarkholme - Not that it should allow multiple nodes, just warn that the {{binding}} will have no output if placed in the root, outside of a div. If my code is:
I would expect an error saying 'title cannot be rendered here as it is outside the root node'. currently it runs but produces no output |
@simonmurdock For the record, can you add a reproduction on jsfiddle? Thanks. |
I don't think I can replicate on jsfiddle as I think webpack is required to replicate. But here is how to do it from nothing:
Then I change the generated
|
我觉得这个例子不错 |
To replicate:
I have been tripped up by this a couple of times (vue 2.8.0), where a simple binding outside the root div gives no output to the DOM, but also gives no error, like you would receive if you had two root nodes:
Is there a valid reason to allow bindings like this in the root? If not it is a very small thing but it might help very new users from scratching their head like I did
The text was updated successfully, but these errors were encountered: