vue.js - VueJS:包括一些静态 HTML 和 JS
问题描述
我对来自 mustache 项目的 VueJS 非常陌生。包含 HTML 的常见部分(页脚、谷歌跟踪代码等)非常容易。
我如何对 VueJS 做同样的事情,我阅读的一些方式似乎完全是矫枉过正(编写导入组件)。
我有:
源代码
成分
-- 应用程序.vue
资产
静止的
- 页脚.htm
解决方案
For the html, write components with just a <template>
section.
Importing and using components inside components is very common in Vue,
I wouldn't call it "complete overkill", you can also inject html into an element using the v-html directive, but I wouldn't recommend that for html you've writen yourself.
For the tracking code, it's a bit trickier as you can't just add <script>
tags inside the template part of a component or v-html.
I recommend saving the tracking code as google-tracking.js
, etc and import './google-tracking.js'
in your app.
推荐阅读
- java - JavaFx 通过从另一个控制器调用方法
- vuetify.js - 如何更改 v-text-field 的高度
- c++ - 迭代Kahan求和的最优实现
- kubernetes - cpu 与 requests.memory、pod 与 count/pod 之间有什么不同
- java - Azure Key Vault 在本地工作,但在 azure 云中出现 403 禁止错误
- android - 哪些 SDK 可用于 App Uninstall Analytics
- java - 为什么字母的 ASCII 会通过 .toCharArray() 方法自动转换?
- jenkins - 当 SonarQube 在不同的服务器上而 Jenkins 在不同的服务器上时,sonar.source 属性无效
- c# - 如何在 WPF 项目的 .cs 文件中使用 Textbox 的控件?
- javascript - 映射嵌套对象