dojo.place如何在不包含HTML的情况下传递参数?
我想做这样的事情:
dojo.place(this.message.subject, this.apSubject);
但它在 Dojo 1.7 中抛出异常(我对 Dojo 完全陌生,所以我不知道旧版本下是否有同样的问题)
为了让它工作,我做了:
dojo.place('<span>' + this.message.subject + '</span>', this.apSubject);
它看起来像Dojo 解析 dojo.place
的第一个参数,如果没有 HTML,则会抛出异常。
没有跨度如何使用?
I'd like to do something like this:
dojo.place(this.message.subject, this.apSubject);
But it throw exception in Dojo 1.7 (I'm completely new to Dojo so I don't know if the same problem is under older versions)
To get it work I did:
dojo.place('<span>' + this.message.subject + '</span>', this.apSubject);
It looks like Dojo parse the first parameter of dojo.place
and if there is no HTML it throw exception.
How to use it without spans?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 docs,特别是第一个参数接收内容的描述:
因此,您可以做的一件事是使用您想要的文本创建一个文本节点
,您可以尝试的另一件事是设置innerHTML而不是使用dojo.place:
顺便说一句,在我看来,dojo.place通常有点烦人使用。然而,由于我不经常进行这种 DOM 操作,所以我真的不知道人们更喜欢使用哪些替代方案。
Check the docs, In particular, the description of what the first argument receives:
Therefore, one things you can do is create a text node with the text you want
And another thing you could try would be setting the innerHTML instead of using dojo.place:
BTW, In my humble opinion, dojo.place is normaly kind of annoying to use. However, since I am not often doing this kind of DOM manipulation, I don't really know what are the alternatives people prefer to use.