Why is it that my vue instance has been created but nothing is displayed on the page?

newcomers are just beginning to learn vue + webpack, to build their own step by step. After running the page, the compilation did not report an error, and the page did not report an error. It seems that the vue instance has been created successfully. The < div id= "app" > in index.html < / div > is missing and should be replaced, but the page is blank. I don"t understand. May I ask you:

<head>
    <link rel="stylesheet" href="http://10.0.0.2:111/styles/com.css">
</head>
<body>
    <div id="app"></div>
    <script src="http://http://10.0.0.2:111/scripts/build.js"></script>
</body>

above is index.html

<template>
    <div id="app"></div>
</template>
<script>
    export default {
        name: "app"
    }
</script>
<style scoped></style>

above is App.vue

import Vue from "vue";
import router from "./router";
import store from "./store";
import App from "../../../components/App.vue";
new Vue({
    el : "-sharpapp",
    router,
    store,
    components : {App},
    template : "<App/>",
    created(){
        this.$router.push({name : "index"});
        console.log("create", this);
    },
});
<template>
    <div>{{ name }}</div>
</template>
<script>
    export default {
        data () {
            return{
                name : "hellow",
            }
        },
        created () {
            console.log("index", this);
        },
    }
</script>
<style scoped></style>

above is index.vue

import Vue from "vue";
import VueRouter from "vue-router";
import index from "../../../../components/index.vue";
Vue.use(VueRouter);
const routes = [{path : "/index" , name :"index" , component : index},];
export default new VueRouter({routes})

the previous router configuration was omitted, now make it up.

what is displayed on the actual page of the result is:

<head>
    <link rel="stylesheet" href="http://10.0.0.2:111/styles/com.css">
</head>
<body>
    <!--function(e,n,r,o){return Oe(t,e,n,r,o,!0)}-->
    <script src="http://http://10.0.0.2:111/scripts/build.js"></script>
</body>

the words "created" are output in the console, but without "index", I don"t understand. If you don"t report an error, why is the content in index.vue not generated? I think it"s the problem of template pointing and so on. But after searching for a long time, I can"t think of the reason. Please give us some advice.


Gee, you naturally won't show this. Index.vue has not been introduced anywhere, how can it appear?
if you want to use this component in the App.vue file, there are two ways.
first, introduce this file into App.vue, separately and add the components option, and then use it in the template template.
the second is to use the router-view component in App.vue and add route maps to router/index.js. If you see in your example, calling $router.push, in the root instance of Vue, then there are three problems. 1. Router-view 2. Is not used in the root instance template. Route 3 is not registered in router/index.js. Usually I don't do this in new Vue. Let's create a demo using vue-cli.

for the first method above, using vue-cli 3.0, create a demo, and take a look at the HelloWorld.vue and App.vue files in it.
it is recommended that you first take a look at the various options and single-file components of Vue instantiation.


there is a problem with your webpack.config configuration. Your vue is misreferenced. Please refer to the vue-cli alias configuration. Your template is invalid.
add the following code to your webpack.config:
resolve: {

    alias: {
     'vue$': 'vue/dist/vue.esm.js',
    }
  },

whether routing is configured or not, or try referencing the index component directly in the app component


1. App.vue there is no < router-view >

<div id="app">
  <router-view></router-view>
</div>

2. Route has not been written in main.js , created app has not been rendered

const router = new VueRouter({
  routes: [
    { path: '/', name: 'index', component: index }
  ]
})

What is written in the entry file in

package.json .

you might as well upload the code to a website such as github so that people will know where you are wrong


I have to write the wrong path

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b92-2bdc3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b92-2bdc3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?