【问题标题】:How to modify the index html in vue cli?如何在 vue cli 中修改 index html?
【发布时间】:2020-06-19 20:42:05
【问题描述】:

我想在vue cli构建过程中修改index html。 (vue.config.js)

有没有办法做到这一点?

这是我的索引 html 的样子:

<!DOCTYPE html>
<html lang="en">
  <head>

    <%= foo %>

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta charset="utf-8" />

    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title>blabla</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, minimal-ui" />
  </head>
  <body>
    <noscript>
      <strong>We're sorry but tera.com-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
  </body>
</html>

我希望 vue/webpack 将值 1 解析为 foo

【问题讨论】:

    标签: vue.js webpack indexing vue-cli


    【解决方案1】:

    Vue 将附加到 ID 为 app 的 DIV。因此,您的 {{foo}} 将超出 Vue 更改它的范围。

    您应该查看Single File Components,这样您就可以将整个 HTML 包装在 Vue 中。

    【讨论】:

    • 没有。我不谈论 vue 中的 {{}}(通过 vue 引擎)。只是为了使用 vue cli 从 webpack 绑定变量。
    • 嗯,你改变了你的来源,所以我的回答现在无关紧要了。你应该标记webpack
    猜你喜欢
    • 2019-03-08
    • 1970-01-01
    • 2021-08-20
    • 2019-07-12
    • 2020-09-03
    • 2018-09-15
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    相关资源
    最近更新 更多