首页 > 解决方案 > VueJS:包括一些静态 HTML 和 JS

问题描述

我对来自 mustache 项目的 VueJS 非常陌生。包含 HTML 的常见部分(页脚、谷歌跟踪代码等)非常容易。

我如何对 VueJS 做同样的事情,我阅读的一些方式似乎完全是矫枉过正(编写导入组件)。

我有:

源代码

静止的

标签: vue.js

解决方案


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.


推荐阅读