我正在使用 vue cli 3 构建一个 chrome 扩展。我的基础知识运行良好,但我希望还可以通过构建过程运行我的内容和后台 javascript,而不是仅仅将它们放入我的公共文件夹中并将其复制到区。这主要是为了让我可以使用导入/导出来清理我的文件结构。
我能够将它们添加为 vue 配置中的新“页面”,即使没有 html 模板文件,它们也会正确构建并移动到 dist 中。
问题是,然后他们将缓存破坏字符串附加到其文件名中,因此我无法在扩展清单中引用它们。例如,background.js变为background.d8f9c902.js
是否可以告诉 vue 配置某些“页面”不应被缓存清除?这里的文档似乎没有将其公开为参数。
提前致谢!
这是我第一次制作 npm 包,我正在制作包的演示,我想放一个组件使用的示例。
当我将组件用法放入 pre 和 code 标记中时,如下所示
它显示这个错误
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.
Run Code Online (Sandbox Code Playgroud)
这是我的代码(App.vue):
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.
Run Code Online (Sandbox Code Playgroud)
我希望它像 HTML 中的普通标签一样工作。我已经尝试下载一些代码块 npm 包,它仍然不起作用,我需要你们的帮助和建议,感谢您的帮助
我刚刚通过 Vue CLI 创建了一个新的 Vue 应用程序,但我无法使用 debugger 或 console.log,否则我会在浏览器中收到错误,为什么以及如何允许它?
Unexpected 'debugger' statement (no-debugger) at src/components/SomeComponent.vue:48:7
Run Code Online (Sandbox Code Playgroud) 如何覆盖vuetify中的实际类?
我创建了一个./src/stylus/main.styl文件,在其中我覆盖了一些当前的vuetify设置作为测试:
@import '~vuetify/src/stylus/settings/_variables'
@import '~vuetify/src/stylus/elements/_typography'
$material-dark.background = green
$body-font-family = Arial
$alert-font-size = 18px
.display-2
font-size: $headings.h6.size !important
font-family: $headings.h3.font-family !important
@import '~vuetify/src/stylus/main'
Run Code Online (Sandbox Code Playgroud)
由于某些原因,以上值仅部分起作用。分配给新的价值观$material-dark.background和 $body-font-family下做工精细的东西theme--dark但是,当涉及到.display-2这些值仍呼吁双方原来的设置font-size,并 font-family与覆盖我加入到main.styl的人。我什至尝试过在包含.display-2手写笔的第一个组件中进入范围内的语言,该组件无法正常工作,然后在纯CSS中工作,该组件不会引发错误,但会被app.xxx.css和chunk-vendor中生成的Vuetify原始默认值覆盖。 xxx.css文件。
//component
<style scoped>
h1.display-2{
font-size:20px;
font-family: "Times New Roman";
color:green;
}
</style>
Run Code Online (Sandbox Code Playgroud)
是否有一个原因?
我做了一些研究,但找不到解决这种情况的快速方法:
Vue-cli 3.4.0 - Webpack 4.29.0
Run Code Online (Sandbox Code Playgroud)
config/index.js提到的。cli-plugin-eslint包裹。.eslintrc.js。- - 使固定 - -
我意识到我没有很好地控制我的设置。它建于vetur。
我想导入一个 JSON 文件来使用它,我需要它在未来修改它所以我把它放在public文件夹 not 中assets,当我这样引用它时import JSON from ../../public/Data.json它可以工作,但我不认为在构建项目后可以解决因为构建后没有public文件夹。所以我试过这个:
let addr = process.env.BASE_URL;
import JSON from `${addr}Data.json`;
Run Code Online (Sandbox Code Playgroud)
但它抛出一个错误:SyntaxError 我现在很困惑哪种方式最好,还有另一种方式吗?
我安装了 vue-cli 3。我尝试使用 vue create 创建一个 vue 应用程序,但我没有收到这样的文件错误。
~$ vue create hello-world
bash: /usr/local/bin/vue: No such file or directory
Run Code Online (Sandbox Code Playgroud)
安装 vue/cli3
yarn global v0.15.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed @vue/cli@3.12.0 with binaries:
- vue
Done in 1.69s.
Run Code Online (Sandbox Code Playgroud) 我是 vue js 新手,目前正在尝试将任何 vue 插件/组件导入其他 sfc .vue 文件中以供使用。
目前,我正在使用带有vue create projectcli 设置的 VS 代码,在我的主App.vue文件中,我尝试在通过 npm 安装后导入插件。
我在很多地方都遇到过这段代码,但不确定它是从哪里导入的。还不确定这个路径系统是如何工作的?
import SomePlugin from 'some-plugin';
Run Code Online (Sandbox Code Playgroud)
我的猜测是,它位于 npm install cli 部分之后的 node_modules 文件夹中。我们是否需要包含 node_modules 文件夹的完整路径,或者 vue-cli 会自动处理这个问题,因为完整路径看起来很奇怪。
import SomePlugin from '../node_modules/some-plugin';
Run Code Online (Sandbox Code Playgroud) 为生产而构建时,Vue CLI v3始终创建“ dist / report.html”。这是一个webpack捆绑分析器报告。
我找不到停止构建该文件的方法。
构建用于生产的Vue CLI 3应用程序时如何避免创建“ report.html”?
这是我的package.json脚本:
"scripts": {
"dev": "npm run serve",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
},
Run Code Online (Sandbox Code Playgroud) 路线更改不会滚动到顶部,因此 Vue 创建者建议使用导航守卫。在更新版本中:
Router.beforeEach(function (to, from, next) {
window.scrollTo(0, 0)
next();
})
Run Code Online (Sandbox Code Playgroud)
完美,除了它在我的应用程序中产生这个致命错误: ncaught TypeError: vue_router__WEBPACK_IMPORTED_MODULE_1__.default.beforeEach is not a function
为什么?
以防万一这是我完整的 router.js 文件:
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import PastEvents from './views/PastEvents.vue'
import BasicPage from './views/BasicPage.vue'
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/past-events',
name: 'past-events',
component: PastEvents
},
{
path: '/basic-page',
name: 'basic-page',
component: BasicPage …Run Code Online (Sandbox Code Playgroud) vue-cli-3 ×13
vue.js ×13
vue-cli ×4
vuejs2 ×4
javascript ×3
eslint ×2
npm ×1
stylus ×1
typescript ×1
vetur ×1
vue-router ×1
vuetify.js ×1
webpack ×1