[
[
[email protected]2021-02-09 12:25:23
Vue.js
[email protected], 2021-02-09 12:25:23

Vue 3 is it possible to mount on an event?

In the process of developing the site, the task arose to show the generated page element on Vue 3 by event, that is, until some kind of event occurs, vue should not replace what is inside the vue-tag-name tag (the same #app)
since initially there is another necessary content generated by the server side of the site
here is an example of how everything is roughly arranged manual assembly of vue 3 + webpack in the resulting file there should be no vue directives, this is not a SPA or MPA, just some elements of the site are implemented on vue.

import { createApp } from 'vue';
import App from '../components/App.vue';

createApp(App).mount('vue-tag-name') // работает но заменяет сразу

var app = createApp(App);
 $(window).on('scroll', function(){
            app.mount('vue-tag-name');
    }); // не работает заменяет на пустоту но без ошибок

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Anton, 2021-02-09
@ZSarKZ

The code is working, most likely, the event is simply not called. Probably the output agent should be hung up on other element.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question