<template>
<div>
<h1>Hello Ashish</h1>
<h2>{{name}}</h2>
</div>
</template>
<script>
export default {
name: "Temp",
};
</script>
app.vue
<template>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<!-- <HomeComp msg="Hello Harshal"/> -->
<!-- <ForLoop/> -->
<Temp/>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
// import HomeComp from './components/HomeComp.vue';
// import ForLoop from './components/ForLoop.vue';
import Temp from './components/Temp.vue';
export default {
name: 'App',
components: {
HelloWorld,
// HomeComp,
// ForLoop
// Demo,
Temp
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
如果您不想更改组件名称:
'vue/multi-word-component-names': 'off',
(取自上面@LifeCoder的响应,但由于我的声誉而无法将其添加为评论)
Mytemp
,而不是Temp.
。 您可以重命名组件或禁用鳞片规则。
"rules": {"vue/multi-word-component-names": "off"}
topackage.json中的eslintconfig
您可以将此代码添加到您的项目:
{
"vue/multi-word-component-names": ["error", {
"ignores": []
}]
}
我建议更改组件的名称。临时到mytemp. so替换每个您的临时位置
尝试重命名这样的声明部分,而不是mytempconst { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
// Add this line of code to disable lintOnSave
lintOnSave: false
})
在您的组件中
Export default {
Name : '( this name )'
这个名称应该是多字
例如(mytepm)📛
(MyTemp)🟢
在
TempComp.vue
或烤肉串格式:
其他格式(例如
tempComp
或
temp-Comp
都被接受,但它们看起来不好
有关更多详细信息,请检查rule-details
默认情况下,如果您不在项目中创建多个字组件,那么Lint就会对您吠叫。这是一个很好的做法,因为它是防止名称冲突的。一个项目可以具有组件名称模式,并且同一名称可以在您的项目依赖的其他几个不同项目中显示。 解决问题,您可以尝试创建诸如
MyModal
或'mycompanymodal`.的多字组件。 请记住,尽管这应该可以防止冲突,但如果您的组件本质上是多词组件,则不会属于该规则。尽管它仍然有犯有冲突的风险。 (即登录模式,登录页....)
如果您希望保留组件的名称,则可以简单地要求皮棉忽略多字组件规则:
#eslint.config.js
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ["resources/**/*.{js,mjs,cjs,vue}"],
rules: {
'vue/multi-word-component-names': ["error", {
"ignores": ['Checkbox', 'Dropdown']
}]
}
},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...pluginVue.configs["flat/essential"]
];
ignores
键中定义的一个。
这通常是在您的配置文件中。您需要确定配置的文件是什么。以我为例