D
D
developer0072019-08-15 11:04:25
JavaScript
developer007, 2019-08-15 11:04:25

Why are the variable and component not displayed?

I have an app.js with this code:

import Vue from 'vue';

Vue.component('user-name', {
    props: ['name'],
    template: '<p>Hi {{ name }}</p>'
});

new Vue({
    el: "#headerApp",
    mounted(){
        alert(2);
    }
});

I also have an index.php in which the script src of the compiled js bundle occurs, and in the body it is
<div id="headerApp">
            <user-name name="Flavio">!</user-name>!
        </div>

So.
alert fires, but the component doesn't render. There are no errors in the console.
If you build using gulp, then everything works.
But the task is to fasten webpack

Here is webpack.config.common.js : https://pastebin.com/K2xtumpD
Then it is merged with the prod: https://pastebin.com/DaJXneis
Why is nothing displayed? , and alert works?
----------------
And if you add a variable:
<div id="headerApp">{{test}}
            <user-name name="Flavio">!</user-name>!
        </div>

new Vue({
    el: "#headerApp",
    mounted(){
        alert(2);
    },
    data() {
        return {
            test: 222,
        };
    },
});

then everything is also empty.
By the way, when the alert fires, you can see the variable {{test}} (template tag)
then everything disappears

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
developer007, 2019-08-15
@developer007

the answer is here https://stackoverflow.com/questions/49334815/vue-r...
this shit needs to be like this alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': helpers.root('src')
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question