添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
鬼畜的回锅肉  ·  Canva SVG and ...·  6 天前    · 
正直的手电筒  ·  Seamless Leopard ...·  6 天前    · 
读研的山楂  ·  Digital Planner ...·  6 天前    · 
还单身的脆皮肠  ·  Editable Retro Style ...·  6 天前    · 
捣蛋的硬盘  ·  如何在JSP (使用Spring ...·  1 周前    · 
大鼻子的小虾米  ·  javascript - ...·  1 年前    · 
欢乐的甜瓜  ·  Control of oxidative ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams template: '<svg xmlns="http://www.w3.org/2000/svg" :viewBox="viewBox" :width="width" :height="height"></svg>',

0 0 + width + height doesn't work, how to fix it? Im new in Vue.js.

Thanks!

In addition to the fact that you should define viewBox as a computed value like @ittus pointed out, 0 0 + width + height does not evaluate to a string because:

a) 0 0 is not valid javascript ( Uncaught SyntaxError: Unexpected number )

b) width and height are both numbers. 0 + width + height would evaluate to a number, 48 by default.

Use one of the following to create a string:

Concatenation ( Read more here ):

viewBox: {
    default: '0 0 ' + this.width + ' ' + this.height

or a template literal (Read more here):

viewBox: {
    default: `0 0 ${this.width} ${this.height}`
template: '<svg xmlns="http://www.w3.org/2000/svg" :viewBox="viewBox" :width="width" :height="height"></svg>',
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.