Tag Archives: front end

[Solved] ant design pro vue Startup Error: ERROR Failed to compile with 1 error 20:34:09 error in ./src/components/Num

Error reporting information

ERROR Failed to compile with 1 error 20:34:09

error in ./src/components/NumberInfo/NumberInfo.vue?vue&type=style&index=0&id=4370c5af&lang=less&scoped=true&

Syntax Error: TypeError: Cannot set properties of undefined (setting ‘parent’)

Delete the NumberInfo folder under the components folder, start the project again, and after starting, Ctrl + z to withdraw the deleted NumberInfo component folder, after which the project will start normally

Solution:

1. Delete, yarn run serve to start project

2. Withdrawal

3. Project started successfully

[Solved] Vue3.2 component computed Error: Write operation failed: computed value is readonly

<template>
	<component
        ref="formComponent"
        :is="formComponent"
    />
</template>

<script setup lang='ts'>
	const mapComp: any = {
	  Record
	};
	const formComponent = computed(() => {
	  return mapComp[route.params.type as keyof typeof mapComp];
	});
</script>

Then the browser reports two warnings

 

After modification:

<template>
	<component
        ref="formComponent"
		:is="mapComp[route.params.type as string]"
    />
</template>

<script setup lang='ts'>
	import {useRoute} from 'vue-router'
	const route = useRoute()
	
	const mapComp: any = {
	  Record
	};
	const formComponent = ref<string>(route.params.type as string);
</script>

At this point, the problem is solved

[Solved] Vue2.x vue-lazyload Error: Failed to resolve directive: lazy

Today, I want to realize the lazy loading of pictures. After registering components according to the tutorial, the console will report an error as above

The version in package.json is found to be the default downloaded version 3.0.0-rc.2

Solution:

Try to modify the version to 1.3.3

"dependencies": {
    "axios": "^0.27.2",
    "core-js": "^3.8.3",
    "element-ui": "^2.15.9",
    "vue-lazyload": "^1.3.3",
    "vue": "^2.6.14",
    "vue-router": "^3.1.3"
  },

Run, no more errors!

[Vue warn]: Invalid prop: custom validator check failed for prop “index“

[Vue warn]: Invalid prop: custom validator check failed for prop “index“

Foreword: I am watching the background management project of bilibili, the error reporting problems encountered and the solutions

report errors:

Original code:

Modification code:

 <el-menu
    default-active="1-4-1"
    class="el-menu-vertical-demo"
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
  >
    <el-menu-item
      v-for="item in noChildren"
      :index="item.path"
      :key="item.path"
    >
      <i :class="'el-icon-' + item.icon"></i>
      <span slot="title">{{ item.label }}</span>
    </el-menu-item>
    <el-submenu
      v-for="item in hasChildren"
      :index="item.path + ''"
      :key="item.path"
    >
      <template slot="title">
        <i :class="'el-icon-' + item.icon"></i>
        <span slot="title">{{ item.label }}</span>
      </template>
      <el-menu-item-group
        v-for="(subItem, subIndex) in item.children"
        :key="item.path"
      >
        <el-menu-item :index="subIndex + ''">{{ subItem.label }}</el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>

 

[Vue warn]: Invalid prop: custom validator check failed for prop “navigationBarTextStyle“.

[Vue warn]: Invalid prop: custom validator check failed for prop “navigationBarTextStyle“.

uniapp,h5 interface report an error:

“globalStyle”: {
“navigationBarTextStyle”: “white”,
“navigationBarTitleText”: “uni-app”,
“navigationBarBackgroundColor”: “#ffaaff”,
“backgroundColor”: “#00ff00”,
“enablePullDownRefresh”: true,
“backgroundTextStyle”: “light”
}

 

Reason & Solution:

The navigationBarTextStyle property can only be filled with white or black, not with hexadecimal

 

[Solved] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection…

USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: The devices connected to the system are not functioning.

When executing automated tests in python + selenium + pytest, I encountered the following error.

[25612:15512:0220/162104.300:ERROR:device_event_log_impl.cc(211)] [16:21:04.299] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection:
 The devices connected to the system are not functioning.(0x1F)

At present, the reason has not been found and can only be solved by violence:

Add the following options when starting chrome:

option = webdriver.chromeOptions()

# Prevent printing some useless logs
option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
driver = webdriver.Chrome(chrome_options=option)

 

Supplement

For this statement

driver = webdriver.Chrome(chrome_options=option)

For chrome browsers, chrome_options=option, preferably written as options=option, that is:

driver = webdriver.Chrome(options=option)

Or you’ll see it in terminal

DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(chrome_options=option)

[Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist

Project scenario:

In the process of testing 3D effects, there was a problem with vite suddenly. I found many methods on the Internet and didn’t know where the problem was.

Problem description

This is the error code of VSC. The error code running on HBx is different from this.


Solution:

Use after downloading yarn

yarn install

After reinstalling the dependency, you can run it

I don’t know why, because NPM run serve will also fail to get after vite is packaged

npm run build
npm run serve

You can build first and then serve.

[Solved] Vue3 Error: Failed to resolve component:xxx

I use vite+typescript+pinia to develop the vue3 project, because I have just come into contact with this problem recently. Look at the code first:

<script lang="ts" setup name="XtxMore">
</script>
<template>
  <RouterLink
    to="/"
    class="xtx-more"
  >
    <span>
      <slot>Check All</slot>
    </span>
    <i class="iconfont icon-angle-right"></i>
  </RouterLink>
</template>

At this time, an error will be reported in the console:

This is because when we name the component, that is, when we add the name attribute to the component, there is no content in the script tag, which will lead to the failure of parsing and the error will be reported.

Just add something in the script tag

<script lang="ts" setup name="XtxMore">
defineProps()
</script>
<template>
  <RouterLink class="xtx-more">
    <span>
      <slot>Check All</slot>
    </span>
    <i class="iconfont icon-angle-right"></i>
  </RouterLink>
</template>

 

[Solved] webpack Package Error: ERROR in multi ./src/main.js ./dist/bundle.js Module not found: Error: Can‘t resolv

When I first came into contact with webpack, I encountered several problems. After successfully installing the latest version of webpack and cli, there was a problem with the first package. In fact, it was also a syntax error

When running webpack .\src\main.js .\dist\bundle.js and packaging, the following error occurs:

Cause of error:

The latest version of the webpack command has changed

Solution:

Add a -o to the previous command.
run webpack .\src\main.js -o .\dist\bundle.js

[How to Solve] Unexpected space before function parentheses Error

Unexpected space before function parentheses error reporting solution

Unexpected space before function parentheses

this error is the configuration in .eslintrc.js file. Add code to the rules in this file:

"space-before-function-paren": 0

Or the attribute space-before-function-paren already exists in the file. Visit the eslint document
to view the parameters and change them according to the document.

[Solved] el-tree setCheckedNodes Error: undefined (reading setCheckedNodes)

Summary:

Today, there is a requirement to write an EL tree in the sub-component (pop-up window) because it needs to be echoed, that is, once you click in, there will be the last checked one.

By checking the document, I think setcheckednodes are the most suitable. Then I click in and show it. My first reaction is to call the following method when mounting

setCheckedNodes() {
    this.$nextTick(() => {
        this.$refs.tree.setCheckedNodes(this.selectedAssign);
    });
},

Codes to report errors:

(spring window subassembly)

<template>
  <div class="dialog">
    <el-dialog
      title="权限分配"
      :visible.sync="dialogVisible"
      width="45%"
      top="8vh"
      ref="tk"
      :before-close="dialogClose"
    >
      <div class="dialog-mid">        
        <div class="online-detail">
          
          <div class="od-content">
            <div class="select-box">
              <div class="all-select">
                <div class="all-tit"><span></span></div>
                <div class="all-con">
                  <el-tree
                    :data="assignData"
                    show-checkbox
                    default-expand-all
                    node-key="id"
                    ref="tree"
                    :highlight-current="true"
                    :props="defaultProps"
                    @check-change="checkChange"
                  >
                  </el-tree>
                </div>
              </div>
            </div>            
          </div>
        </div>
        <div class="foot-botton">
          <el-button type="primary" @click="open">提交修改</el-button>
          <el-button @click="dialogClose">取消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["dialogVisible"],
  data() {
    return {      
      assignData: [
        {
          id: 1,
          label: "1",
          children: [
            {
              id: 101,
              label: "101",
            },
            {
              id: 102,
              label: "102",
            },
          ],
        },
        {
          id: 2,
          label: "2",
          children: [
            {
              id: 201,
              label: "201",
            },
            {
              id: 202,
              label: "202",
            },
            {
              id: 203,
              label: "203",
            },
            {
              id: 204,
              label: "204",
            },
            {
              id: 205,
              label: "205",
            },
          ],
        },
        {
          id: 3,
          label: "3",
          children: [
            {
              id: 301,
              label: "301",
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
      selectedAssigns: [
         {
           id: 1,
           label: "1"
         },
         {
           id: 101,
           label: "101",
         },
         {
           id: 102,
           label: "102",
         },
      ],
    };
  },
  methods: {
    dialogSure() {
      this.$emit("dialogSure");
    },
    dialogClose() {
      this.$parent.dialogClose();
    },
    open() {
      this.$confirm("This action will change the privileges of this user, do you want to continue?" , "prompt", {
        confirmButtonText: "YES",
        cancelButtonText: "NO",
        type: "warning",
      })
        .then(() => {
          // this.dialogVisible = false;
          this.dialogSure();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "Modified Canceled",
          });
        });
    },

  

    

    setCheckedNodes() {    
      this.$nextTick(() => {
          console.log(this.$refs.tree,"this.$refs.tree");
          this.$refs.tree.setCheckedNodes(this.selectedAssigns);
      });
    },

    resetChecked() {
      this.$refs.tree.setCheckedKeys([]);
    },
  },
  mounted() {
    // Set the screen height to 90%
    this.$refs.tk.$el.firstChild.style.height = "70%";
    this.setCheckedNodes(); // ready to be called at the time of the popup mount will be able to click in and have a display back, but there is an error, 148 print out the result is undefined
    // this.$nextTick(() => { // Go online and check what others have written and say to use this.$nextTick when mounting.
    //   this.setCheckedNodes();
    // });
  },
};
</script>

<style scoped>

</style>

I thought I could call it when the pop-up window was mounted, and there was an echo when I clicked it, but there was an error, and the result printed out by 148 was undefined.

The error information is shown in the figure:

Seeing such error reporting experience tells me that when I execute this method, the dom of the pop-up window has not been created, and I can’t find this tree, but it’s strange that I clearly wrote this in this method$ Nexttick (this.$nexttick function can make the methods in it run after the DOM is created), and any operations are in this$ Nexttick.

Check others’ writing methods on the Internet and say you want to use this$ Nexttick is written when it is mounted. Then there is the section of code commented out in the mount, but it still reports an error, and the same error is reported.

I guessed that the DOM of the popup window was created after clicking to open the popup window, so I opened the popup window in the parent component in the method this.dialogVisible = true; and then went to call the setCheckedNodes method

How to call it? There is a very simple way to write the method of the parent component calling the child component, which is to give a ref= “dialog” on the child component

For example:

<Dialog :dialogVisible="dialogVisible" @dialogSure="dialogSure" ref="dialog"></Dialog>

Then call the method of the sub component in the method of opening this pop-up window: //selectedAssign is the starting array, which can be passed from the parent component

handleAssign(row,selectedAssign) {
    //selectedAssign is the starting array, which can be passed from the parent component
      this.dialogVisible = true;
      this.$refs.dialog.setCheckedNodes(selectedAssign);
},

Finally, save, refresh and re run, there will be no error, and there will be starting data.