vue + vite 在index.html中使用环境变量

  1. npm install vite-plugin-html -D
  2. vite.config.js
return {
  plugins: [
   useHtmlLoader({
    inject: {
    data: {
      title: 'hello',
    },
  },
}),]}
  1. index.html可以使用啦!!! 太麻烦啦
<p class="url">
   <%= title %>
</p>
posted @ 2023-07-31 10:30  躺尸的大笨鸟  阅读(480)  评论(0)    收藏  举报