2.5.2
https://jsfiddle.net/weituotian/0rc7zq1b/5/
h11111111111111111rerender buttonI hope I can update incrementally so that my html content can be selected back to the previous selection.
If the html changes, then the window.getSelection().addRange can not choose to go back to the previous content.
Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server, gitter or StackOverflow.
You need to set the selection again since Vue is replacing the HTML
@posva
why close my issue!
it is not solve!
your solution is not work! you don konw the meaning of this issue!
My bad, it doesn't work! I updated my comment to better reflect why I closed the issue :wink:
@posva
If your technique is very powerful, give me some advice.
it is because vue update the html, and there is impossible to reselect the previous selection!!!
Vue should be responsible for the issue after updating the dom element!
not only v-html, every component which been updated by vue also hava a reselect issue!
now you understand the real meaning of this issue???
Calm down plz.
it is because vue update the html, and there is impossible to reselect the previous selection!!!
Of course you can, you just need to decide how to record previous selections yourself, even with v-html.
Vue should be responsible for the issue after updating the dom element!
Absolutely not. By using v-html like this you are explicitly re-rendering all existing content, that's why the selections are discarded. If you are just appending content, just try to keep previous content as much as possible and the selection will be preserved.
You can check on this: http://jsfiddle.net/eywraw8t/143042/
And btw, don't take free help for granted.
@Justineo The example may be written in error, It should be so
this.contents.push(Math.floor(Math.random() * 3))
Most helpful comment
Calm down plz.
Of course you can, you just need to decide how to record previous selections yourself, even with
v-html.Absolutely not. By using
v-htmllike this you are explicitly re-rendering all existing content, that's why the selections are discarded. If you are just appending content, just try to keep previous content as much as possible and the selection will be preserved.You can check on this: http://jsfiddle.net/eywraw8t/143042/
And btw, don't take free help for granted.