search

Home  >  Q&A  >  body text

javascript - How to implement jquery's append method without operating dom in react or vue?

Sometimes you need to add some HTML locally. If you add traversal rendering to the array like React, all the array data will have to be re-rendered. I just want to render the original one to be added without re-rendering, so how to implement jquery append?

漂亮男人漂亮男人2754 days ago494

reply all(5)I'll reply

  • 为情所困

    为情所困2017-05-19 10:27:42

    Don’t use jQuery thinking to write react or vue, think in react, thinking in vue.

    Let the framework do the dirty work of updating the DOM for you. You only need to care about your data or state.

    You regard the extra thing you want to add as a component. According to your needs, this component will not render at first, and then something is triggered, and this component will be rendered. Isn't this "conditional rendering"? If you look at the documentation of vue and react, how do you write conditional rendering?

    What can I do if I re-render everything every time? It just executes your render function, and there is also a layer of virtual DOM diff. The actual operation on the DOM is equivalent to you executing jQuery's append.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-19 10:27:42

    The framework will help you complete minimal updates

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:27:42

    React: If you plan the Component correctly and use the key attribute, the DOM operation should only have a set equivalent to append

    reply
    0
  • PHP中文网

    PHP中文网2017-05-19 10:27:42

    Since you are developing with rect or vue, you have to abandon the idea of ​​using jquery. It is recommended to read more vue react documentation

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:27:42

    Give up jq, start with me

    reply
    0
  • Cancelreply