javascript - How vue template simulates the destructuring props feature in jsx
PHP中文网
PHP中文网 2017-05-19 10:19:07
0
2
993

We know that in jsx you can assign values to props like this

const props = { a: 1, b: 1, } render() { return (  ) }

In vue, although I am able to do this

 // ... data() { return { props: { a: 1, b: 1, }, }, },

But the difference from the above is that my-comp actually only receives a prop ofsome-props(an object attribute), instead of gettinga## like jsx #,bTwo props (properties with value expansion).

The difference between object properties and expanded properties is that the former is inconvenient for props verification.

If I want to achieve the same effect as jsx, I have to write like this

 // ... data() { return { props: { a: 1, b: 1, }, }, },

It’s super annoying to write like this, because you often have to write a lot of props.

Then the question is, is it possible to implement the abbreviation in jsx in vue?

PHP中文网
PHP中文网

认证0级讲师

reply all (2)
我想大声告诉你

Pay attention. Also, what about this?

 // ... data() { return { props: { a: 1, b: 1, }, }, },
    習慣沉默

    Then write jsx in the render function instead of template? Escape

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!