- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个项目想要使用 VuePress 进行记录,并且我有一个需要 jQuery 才能运行的小代码。我知道您可以添加内联脚本标签并将代码放入其中,但我似乎无法添加 jQuery。这是文件夹结构和我尝试过的内容:
docs
.vuepress
-- dist
-- public
-- css
-- js
-- jquery-3.3.1.min.js
-- scripts.js
-- config.js
components.md
在 Components.md 中,我在末尾添加了以下内容:
<script src="/js/jquery-3.3.1.min.js"></script>
在脚本标签中添加jquery时出现错误:
Module not found: Error: Can't resolve '../../../../../../js/jquery-3.3.1.min.js?vue&type=script&lang=js&' in C:/Users/../docs
@ ./node_modules/vuepress/lib/app/.temp/routes.js
@ ./node_modules/vuepress/lib/app/app.js
@ ./node_modules/vuepress/lib/app/clientEntry.js
@ multi ./node_modules/vuepress/lib/app/clientEntry.js
在 module.exports.head
的 config.js 中添加 css 有效,但由于某种原因,添加 javascript 不起作用(添加了 jquery,但有时它有效,而且大多数时候它没有)。这是我在 config.js 中尝试的内容
head: [
["link",{ rel: "stylesheet", href: "/css/bootstrap-4.1.3/bootstrap reboot.css" } ],
["link",{ rel: "stylesheet", href: "/css/bootstrap-4.1.3/bootstrap-grid.css"}],
["link", { rel: "stylesheet", href: "/css/bootstrap-custom.css" }],
["link", { rel: "stylesheet", href: "/css/style.css" }],
["script", { src: "/js/jquery-3.3.1.min.js" }],
["script", { src: "/js/scripts.js" }]
]
编辑:我进行了更多测试,显然,即使导入了脚本,我也无法选择我想要选择的元素。例如 $('.my-elements') 返回一个空选择器。另一方面, document.getElementsByClassName('my-elements') 可以工作并显示我想要作为第一个数组元素的元素,但如果我想选择末尾带有 [0] 的第一个数组元素,它将返回未定义。 p>
我尝试使用上面的 2 个函数在控制台中选择元素。相同的功能在控制台中有效,但在脚本中不起作用,这很奇怪。
最佳答案
在
.vuepress/config.js
添加脚本
module.exports = {
head: [
['script', {src: 'https://code.jquery.com/jquery-3.4.1.min.js'}]
]
}
有关头配置的更多文档
jQuery CDN
关于javascript - 如何将 jQuery 添加到 VuePress 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52836660/
想知道是否有一种简单的方法可以为 Vuepress 文档添加自定义标题 Material 。 在我当前的项目中,我使用的是 Turbolinks。当我访问用 Vuepress 编写的文档时,Turbo
默认情况下,VuePress 似乎只支持少数几种语言来进行语法高亮(也使用默认主题)。 文档经常提到“行高亮”,但这是一个完全不同的功能,可以在代码片段中高亮显示特定行。我正在寻找在 Scheme、J
我认为 Vuepress 的左 Pane 太宽了。想知道是否有任何设置可以减少左侧面板的宽度? 最佳答案 在.vuepress文件夹中添加文件override.styl,并添加如下行设置侧面板宽度(默
我想将相关 Assets 与相关 Markdown 放在同一文件夹中。 +-- README.md +-- some-folder | +-- index.md | +-- img |
是否可以在不弹出和更改整个主题的情况下更改/自定义 Vuepress 的 404 页面? 我目前正在使用 enhanceApp.js ,但我不确定如何更改路由器选项(catchall 路由),因为路由
目前房产mode vuepress 中的 vue 路由器是“历史” 我想更改属性 mode vuepress 中的 vue 路由器到 hash 有没有办法实现这一目标? 我尝试创建了一个文件 enha
我尝试使用插件 register/components 在 vuepress 中添加自定义组件目录,但似乎不可能。 我试过 module.exports = { title: 'Hello Vue
VuePress@next 使用数学公式插件 搞了一个VuePress1.0的 现在升级了一下,但是使用数学公式的插件老报错啊!经过不懈努力,终于搞定了。现在记录一下。 VuePress
我目前正在使用 Vuepress。但是我想要在我的 Vuepress 站点中使用多种语言。经过 3 天的挣扎,我决定把我的问题放在这里。 (是的,我查看了 Vuepress 文档:https://vu
我在本地从github克隆了一个repo,是VuePress相关的代码。在 package.json 文件中只有以下脚本。 "scripts": { "build": "vuepress bu
我正在为我工作的网站构建一个文档网站。 我对提供的 VuePress 核心样式表很满意,但我希望能够从核心样式表中排除页面的特定部分。 例如,我想展示我网站的 CSS 如何呈现标签,我已将我的网站
我正在尝试在 vuepress 中创建一个组件来显示带有标题的图像。当我对图像路径进行硬编码时,图像会出现,但这样我就不会有可重用的组件。我已经尝试使用 Prop ,但它也不起作用。 这是我已经尝试过
有人能告诉我如何部署(=投入生产)我的本地 VuePress 站点吗? 如果我理解正确https://vuepress.vuejs.org/guide/deploy.html ,我们不能在共享主机上部
我正在尝试使用主题继承来修改 VuePress 默认主题导航栏。阅读 1.x 文档后,我相信我正在应用推荐的内容,但网站构建不正确。 我已将 extend = '@vuepress/theme-def
我正在尝试编写一个 Vuepress 插件来利用 App Level 增强并安装一个 Vue 插件。但我似乎无法让它发挥作用。你能看看下面的代码,看看有什么问题吗? {.vuepress/config
我正在尝试使用 vuepress 构建一个静态站点。我有一个使用 javascript fetch 库的 vue 组件。它看起来像这样: {{totalVuePackages}}
我正在尝试按照以下步骤使用我自己的 vuepress 自定义布局: 从 Homepage style 开始在 VuePress 文档中,它运行良好。 为特殊布局制作T4V4Home.vue作为弹出的主
我实际上正在运行一个 Laravel 网站,我想在其中运行 Vuepress 文档部分。 根据说明,安装 Vuepress 非常简单,开发服务器也是如此。 但是,当谈到将其集成为静态站点时,我对与 L
有没有办法配置 vuepress 在默认 /docs 以外的地方查找文件夹 .vuepress? 最佳答案 更新:VuePress 1.5.0 现在只能读取 docs/.vuepress ,因此下面的
将 VuePress 与 Algolia 快速搜索框结合使用。 我在 Algolia 的文档中找不到如何增加下拉列表中显示的结果数量。目前默认为 5。 仅将“hitsPerPage: 10”添加到 c
我是一名优秀的程序员,十分优秀!