vue + vite 在index.html中使用环境变量
- npm install vite-plugin-html -D
- vite.config.js
return {
plugins: [
useHtmlLoader({
inject: {
data: {
title: 'hello',
},
},
}),]}
- index.html可以使用啦!!! 太麻烦啦
<p class="url">
<%= title %>
</p>
return {
plugins: [
useHtmlLoader({
inject: {
data: {
title: 'hello',
},
},
}),]}
<p class="url">
<%= title %>
</p>