1.defineConstantsUncaught SyntaxError: missing) Uncaught SyntaxError: missing) after argument list

defineConstants: {
    BASE_URL:'"/api"',},Copy the code

2,import { getWindowHeight } from "@/utils/utils"Error: module @/utils/global or its corresponding type declaration could not be found

Set the alias of the index.js file in the config folder

const path = require("path"); // Top introduction, don't forget

alias: {
    "@/components": path.resolve(__dirname, ".."."src/components"),
    "@/services": path.resolve(__dirname, ".."."src/services"),
    "@/utils": path.resolve(__dirname, ".."."src/utils"),
    "@/pages": path.resolve(__dirname, ".."."src/pages"),
    "@/icon": path.resolve(__dirname, ".."."src/icon"),},Copy the code

Modify in tsconfig.json file

"paths": {
    "@/component/*": ["src/component/*"]."@/services/*": ["src/services/*"]."@/utils/*": ["src/utils/*"]."@/pages/*": ["src/pages/*"]."@/icon/*": ["src/icon/*"],},// Files managed by ts
"include": [
    "src/**/*.ts"."src/**/*.tsx"."src/**/*.vue",].Copy the code

3, 标 错 : Property “value” was ear, nose and throat surgeon during render but is not defined on instance.

Error: Value is defined in data because return is forgotten

data() {
    return {
        value: ""}; },Copy the code

4, ts does not recognize the. Vue file when importing. Create a new one in the SRC root directory.d.tsSuffix file, put the following code.

declare module '*.vue' {
    import { defineComponent } from 'vue';
    const Component: ReturnType<typeof defineComponent>;
    export default Component;
}
Copy the code

5、 Invalid prop: type check failed for prop “index”. Expected Number with value 12, got String with value “12”.

Reason: The index obtained by the for loop is a String, which is defined as Number in the child component definition.

props: {
    index: {
        type: String.// The Number type is invalid
        default: 0,}}Copy the code

6, Type ‘String’ is not assignable to Type ‘String’, ‘string’ is a primitive, but ‘String’ is a wrapper object. Prefer using ‘string’ when possible.

Cause: Ts files use String, vue files use String