Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

vuejs2 - 在@ vue / cli 4.0.5 app 2“ app” div中做什么?(What for in @vue/cli 4.0.5 app 2 “app” divs?)

In my @vue/cli 4.0.5 app in /public/index.html file I see code with div id=“app”

(在我的/public/index.html文件的@ vue / cli 4.0.5应用程序中,我看到div id =“ app”的代码)

  <body>
    <noscript>
      <strong>We're sorry but vtasks doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app" style=" ></div>
    <!-- built files will be auto injected -->
  </body>

That is clear, but in /src/App.vue file I also see div with “app” id:

(这很明显,但是在/src/App.vue文件中,我还看到了带有“ app” ID的div:)

<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </div>
    <router-view/>
  </div>
</template>

<style lang="scss">
...

That is very confusing, what for 2 "app" divs?

(这非常令人困惑,对于2个“ app” div来说是什么?)

Making some changes with div in /public/index.html I see that it is rendered in my page here...

(在/public/index.html中使用div进行一些更改,我看到它在我的页面中呈现了...)

  ask by Petro Gromovo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The way that webpack (what vue-cli uses) compiles your vue files is into the index.html file so of course you will have the same app basically webpack takes your app from the App.vue and compiles it into the index.html .

(webpack(vue-cli使用的)编译vue文件的方式是进入 index.html文件,因此,当然,您将拥有相同的app基本上webpack将您的应用程序从App.vue并编译为index.html 。)
Generally speaking you don't want to be making changes to a vue app from the index file rather from the vue files.

(一般来说,您不想从索引文件而不是从vue文件对vue应用程序进行更改。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...