Tailwind CSS IntelliSense 不会在 svelte js 应用程序内的 VScode 中自动建议?如果我每次打开 VScode 时重新安装它就可以了

sk *_*aka 9 svelte tailwind-css svelte-3

似乎每次启动 VScode 时 Tailwind CSS IntelliSense 都不起作用,重新安装后它就可以工作,另一方面,当它工作时,Tailwind CSS IntelliSense 不会提示,除非我按空格键。如果我将一门课移至另一门课,除非我按空格键,否则不会建议

我正在使用 Tailwind CSS IntelliSense v0.7.4 ,VScode 1.63.2 ,Ubuntu 21.10

包.json

{
  "name": "svelte-ts-tailwind-app",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "start": "sirv public",
    "check": "svelte-check --tsconfig ./tsconfig.json"
  },
  "devDependencies": {
    "@rollup/plugin-commonjs": "^21.0.0",
    "@rollup/plugin-node-resolve": "^13.0.0",
    "@rollup/plugin-typescript": "^8.3.0",
    "@tsconfig/svelte": "^2.0.1",
    "autoprefixer": "^10.4.0",
    "postcss": "^8.4.4",
    "postcss-load-config": "^3.1.0",
    "rollup": "^2.60.2",
    "rollup-plugin-css-only": "^3.1.0",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^7.1.0",
    "rollup-plugin-terser": "^7.0.2",
    "svelte": "^3.44.2",
    "svelte-check": "^2.2.10",
    "svelte-preprocess": "^4.9.4",
    "tailwindcss": "~3.0.0",
    "tslib": "^2.3.1",
    "typescript": "~4.5.3"
  },
  "dependencies": {
    "sirv-cli": "^1.0.14"
  }
}
Run Code Online (Sandbox Code Playgroud)

tailwind.config.cjs

module.exports = {
  mode:"jit",
  darkMode: 'class', // This can be 'media' if preferred.
  // Don't add a glob below `public` as Rollup doesn't
  // recognize them and will rebuild in an infinite loop.
  content: [
    './src/**/*.svelte',
    './src/**/*.html',
    './public/index.html',
  ],
  theme: {
    extend: {
      colors: {
        svelte: '#ff3e00',
      },
    },
  },
  plugins: [],
}

Run Code Online (Sandbox Code Playgroud)

postcss.config.cjs

module.exports = {
  plugins: [
    require('tailwindcss'),
  ]
};
Run Code Online (Sandbox Code Playgroud)

小智 6

默认情况下,在 VS Code 中,字符串建议的设置为 false,当我们在组件中以字符串形式输入类名时,您必须将其设置为 true,如下所示:

"editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": true,
    }
}
Run Code Online (Sandbox Code Playgroud)


小智 0

尝试使用其他版本的 tailwind 来解决此错误可能有助于解决您的问题。