Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Vue.js Directory Structure

Vue.js Directory Structure

In the previous chapter we used npm to install the project. We open the directory in an IDE (Eclipse, Atom, etc.), and the structure is as follows:

Directory Explanation

Directory/File Description
build Project build (webpack) related code
config Configuration directory, including port numbers, etc. As beginners we can use the defaults.
node_modules Project dependency modules loaded by npm
src

This is the directory we develop in; basically everything to be done is in this directory. It contains several directories and files:

  • assets: place some images, such as logos, etc.
  • components: a component file is placed in this directory, it can be omitted.
  • App.vue: the project entry file; we can also write components directly here instead of using the components directory.
  • main.js: the core file of the project.
  • | | static | Static resources directory, such as images, fonts, etc. | | test | Initial test directory, can be deleted | | .xxxx files | These are some configuration files, including syntax configuration, git configuration, etc. | | index.html | Homepage entry file, you can add some meta information or analytics code etc. | | package.json | Project configuration file. | | README.md | The project's documentation, in markdown format |

    Earlier we opened the APP.vue file, the code is as follows (explained in the comments):

    src/APP.vue

    <
    
    template
    
    <
    
    div
    
    id
    
    =
    
    "
    
    app
    
    "
    
    <
    
    img
    
    src
    
    =
    
    "
    
    ./assets/logo.png
    
    "
    
    <
    
    hello
    
    hello
    
    div
    
    template
    
    <
    
    script

    // import component import Hello from './components/Hello' export default { name: 'app', components: { Hello } }

    script

    <

    style

    #app { font-family: 'Avenir', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; }

    style

    Next we can try to modify the initialized project, changing Hello.vue to the following code:

    src/components/Hello.vue

    <
    
    template
    
    <
    
    div
    
    class
    
    =
    
    "
    
    hello
    
    "
    
    <
    
    h1

    {{ msg }}

    h1

    div

    template

    <

    script

    export default { name: 'hello', data () { return { msg: 'Welcome to Runoob Tutorial!' } } }

    script

    Reopen the page http://localhost:8080/; generally after modification it will refresh automatically, and the displayed effect is as follows: