在使用 Vue CLI 4.5.x 时,我尝试了以下代码:
import Vue from "vue"
import App from './App.vue'
new Vue({
el: "#app",
render: h=> h(App)
})
Run Code Online (Sandbox Code Playgroud)
但不幸的是,它给出了以下警告:
"export 'default' (imported as 'Vue') was not found in 'vue'
我可以从中得出的结论是,Vue CLI 4.5.x 已经停止了这种首先创建 Vue 实例的应用程序创建方式。
初始化主应用程序,官方的方式如下:
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
Run Code Online (Sandbox Code Playgroud)
我不确定我的结论是否正确。如果有人能具体说明我的结论,那将是一个很大的帮助,因为到目前为止我还没有在 vue 的官方文档中找到任何证据。
此外,后面的代码是使用 Vue CLI 4.5.* 应用程序实例烘焙的,而前面的代码在使用 CDN 时是正确的。
我正在使用 Vue 3,我想使用 VS Code(Chrome 扩展调试器)调试标准 Vue 演示。我的 vue.config.js 看起来像这样:
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 launch.json 设置:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
}
},
]
}
Run Code Online (Sandbox Code Playgroud)
启动调试器时,我只能调试编译后的app.js,而不能调试HelloWorld.vue。对我来说,源地图似乎尚未构建。有人可以帮我解决这个问题吗?
要调试的组件 (components/Hello World.vue)
如果有必要:
我正在开发一个项目,我希望能够打印页面的特定元素。有一个名为 VueHtmlToPaper 的 mixin/插件,它完全可以实现我想要的功能,但我无法将其导入到我的 Vue 3 CLI 项目中,因为它是为 VueJS2 创建的,并且全局 API 不同。任何帮助表示赞赏。
main.js
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
Run Code Online (Sandbox Code Playgroud)
项目结构:
我有 vuejs-3 项目,我正在寻找 0 个漏洞。当我执行 npm install 时,当前版本的 node 和 npm 有 48 个漏洞。即使我尝试 npm audit fix --force 问题仍然相同。有人能帮助我吗?
C:\Users\achalapa\git\cnsr-odrplat-wcm-cld-vue\mcafee-consumer-wcm-cld-vue.lib> npm install
-npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
-npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
-npm WARN deprecated har-validator@5.1.5: this library is no longer supported
-npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with …Run Code Online (Sandbox Code Playgroud) 有没有办法追踪这种构建问题?即会显示更详细的错误信息的标志?我的项目非常像默认的 vue cli 项目。直到今天早上,它已经运行了好几个月。
$ vue-cli-service build --mode dev
? Building for dev...
ERROR Failed to compile with 0 errors 12:06:07 PM
ERROR Build failed with errors.
error Command failed with exit code 1.
Run Code Online (Sandbox Code Playgroud) 所以我想将 Axios 添加到 Vue 项目中。我通过发行vue add axios. 它告诉我,安装成功,但后来不知何故出现了 5 个错误。我不完全明白为什么它告诉我它已安装,但似乎仍有一些工作在进行,更重要的是:这个错误是什么?
我猜它实际上安装了 Axios 但它无法生成它通常添加的默认代码?那不好吗?为什么要添加代码?为什么我不能将它用作一种依赖管理器?
$ vue add axios
WARN There are uncommited changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes
Installing vue-cli-plugin-axios...
+ vue-cli-plugin-axios@0.0.4
updated 1 package and audited 25608 packages in 10.502s
40 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
? Successfully installed plugin: vue-cli-plugin-axios
Invoking generator for vue-cli-plugin-axios...
? Running completion hooks...error: …Run Code Online (Sandbox Code Playgroud) 我找不到有关如何使用 vue cli 最小化资产和生成 *.min.js 文件的文档。我使用的是 vue cli 版本 4.2.3。
我需要将扩展名设为 *.min.js 才能使滚动条正常运行。
您将如何配置 vue cli 以生成最小化的资产?(不涉及 TS)。
我的项目正在运行node-sass,但我决定将其更改为sass(dart-sass),因为我想避免安装python、g++并make只是为了运行npm install,而node-sass会因为node-gyp而强制你这样做。
\n所以我跑了
\n$ npm uninstall node-sass\n$ npm install sass\nRun Code Online (Sandbox Code Playgroud)\n运行npm run build( vue-cli-service build) 工作正常,但我的持续集成在npm run test:unit( vue-cli-service test:unit) 上失败。
这是完整的错误:
\n FAIL tests/unit/example.spec.ts\n\xe2\x97\x8f Test suite failed to run[vue-jest] \nError: You are trying to use "scss". node-sass is missing.\n\n To install run: \nnpm install --save-dev node-sass\nat error (node_modules/vue-jest/lib/throw-error.js:2:9)\nat module.exports (node_modules/vue-jest/lib/ensure-require.js:38:5) at module.exports (node_modules/vue-jest/lib/compilers/scss-compiler.js:20:3)\nat processStyleByLang (node_modules/vue-jest/lib/process-style.js:11:82)\nat processStyle (node_modules/vue-jest/lib/process-style.js:20:17)\nat node_modules/vue-jest/lib/process.js:93:13\nat Array.map (<anonymous>)\nat Object.module.exports [as process] (node_modules/vue-jest/lib/process.js:90:8)\nTest Suites: 1 failed, 1 total\nTests: …Run Code Online (Sandbox Code Playgroud) 上周我在创建一个新项目并为其提供服务时没有任何问题,但是今天当我使用 vue/cli 创建一个新的默认项目时,我在服务时出现编译错误。
PS E:\Projects\testing> yarn serve
yarn run v1.22.5
$ vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
ERROR Failed to compile with 1 error ??12:22:33
error in ./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
Module parse failed: Unexpected token (763:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
| class RefImpl {
> _rawValue;
| _shallow;
| _value;
@ ./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js 1:0-233 2:0-216 2:0-216 2:0-216 2:0-216 2:0-216 …Run Code Online (Sandbox Code Playgroud)