简体   繁体   English

如何使用PUG获取VueJS修饰符

[英]How to get VueJS modifiers with PUG

How can we get modifiers with Pug? 我们如何使用哈巴狗获得修饰剂?

I tried the following: 我尝试了以下方法:

my-component(:options.sync="addresses")

my-component(':options.sync'="addresses")

Both of these give a syntax error, unexpected token. 两者都给出语法错误,意外的令牌。

my-component(:options="addresses")

Gets compiled but of course misses the modifier in the final HTML. 获得编译,但当然会错过最终HTML中的修饰符。

If that cannot be achieved with pug, is there any way to integrate raw HTML within a PUG template so that I can specify just that component with HTML and the rest with PUG syntax? 如果用pug无法做到这一点,是否有任何方法可以将原始HTML集成到PUG模板中,以便我可以只用HTML指定该组件,而其余部分则用PUG语法指定?

To answer this part of your question you can output raw HTML with either the pipe or period characters at the end of your element. 要回答问题的这一部分,您可以输出原始HTML,并在元素末尾加上竖线或句点字符。

...is there any way to integrate raw HTML within a PUG template so that I can specify just that component with HTML and the rest with PUG syntax? ...是否有任何方法可以将原始HTML集成到PUG模板中,以便我可以只用HTML指定该组件,而其余部分则用PUG语法指定?

With the pipe at the start of a line you will get the raw output for that line. 将管道置于行的开头,您将获得该行的原始输出。 For example this will render the exact string after the pipe: 例如,这将在管道之后呈现确切的字符串:

| <div>
|   <a href='https://example.com'>Link to site</a>
| </div>

The period is used after a block to output all child elements as raw text. 在块之后使用句点将所有子元素输出为原始文本。 This would output the same HTML as the code block above: 这将输出与上面的代码块相同的HTML:

div.
  <a href='https://example.com'>Link to site</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM