小编STh*_*STh的帖子

Vue:编译失败(字符串必须使用单引号)

我已经使用 Visual Studio Code 两天了。我尝试构建一个 Vue 应用程序。但总是当我通过 运行应用程序时npm run serve,我会收到以下错误:

  9:9   error  Strings must use singlequote  quotes
  9:15  error  Missing trailing comma        comma-dangle

? 2 problems (2 errors, 0 warnings)
  2 errors and 0 warnings potentially fixable with the `--fix` option. 
Run Code Online (Sandbox Code Playgroud)

我理解这些错误的含义,我尝试用单引号输入字符串并在每一行的末尾插入逗号。但是Visual Studio Code总是去掉逗号,把单引号变成双引号……这里可以看到我安装了哪些插件:

在此处输入图片说明

vue.js single-quotes visual-studio-code vuejs2

6
推荐指数
1
解决办法
4685
查看次数

Nuxt3 - 在 GitHub 页面上找不到“_nuxt”目录(404)

(我知道这听起来可能类似于_nuxt 文件夹中缺少 js 文件,但不幸的是,我无法理解那里的答案)

当我将我的dist文件夹部署到 GitHub Pages 时,它包含

dist 
| _nuxt
  | css/main.css
  | entry.*******.css
  | entry-*******.mjs
  | index-*******.mjs
  | history-********.mjs
  | header-********.mjs
  | ... some other mjs-files
| css/main.css
| index.html
| history.html
| ... some other HTML-files
Run Code Online (Sandbox Code Playgroud)

HTML 页面已提供,非常好,并且在<head>- 部分中,他们想要加载模块(.mjs- 文件)。不幸的是,所有这些请求都失败并返回 404:

Chrome 控制台错误 I Chrome控制台错误II

为什么对 -fold 的请求_nuxt失败,而/和 的/css请求却通过?


编辑:刚刚看到在 VS Code 中,该文件夹只是标记为-folder的符号链接.output/public(由 生成nuxi generate):

在此输入图像描述

这可能是问题所在吗?但无论如何,它似乎包含这些文件:

在此输入图像描述


编辑 II:我无法运行npm run …

github-pages nuxt.js mjs github-actions nuxtjs3

6
推荐指数
1
解决办法
2624
查看次数

Vue - 是否可以动态设置 html 元素的样式?

简短版本:data()我的应用程序中,我定义了某些颜色。我希望html根据switch声明将元素的背景设置为这些颜色之一。

长版本: 在 中data(),我有以下代码:

data() {
    return {
      item: {},
      color1: '',
      color2: '',
    };
  },
Run Code Online (Sandbox Code Playgroud)

在我的created()函数中,我从后端获取该项目。此外,我编写了以下代码来评估 - 部分的颜色html

switch (this.item.itemType) {
    case 'car': this.color1 = '#39ac39'; this.color2 = '#00ff00'; break;
    case 'bus': this.color1 = '#3333ff'; this.color2 = '#1a75ff'; break;
    case 'plane': this.color1 = '#ff66cc'; this.color2 = '#ffb3e6'; break;

    default: this.color1 = '#'; this.color2 = '#';
}
Run Code Online (Sandbox Code Playgroud)

在我的style部分中,我想设置整个应用程序(html-tag)的背景样式,样式如下:

data() {
    return {
      item: …
Run Code Online (Sandbox Code Playgroud)

javascript css vue.js vue-component vuejs2

5
推荐指数
1
解决办法
3277
查看次数