Tag Archives: front end

Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)

The reason is that the form item uses v-if control and appears to be between two normal el-form-items. As follows.

Then when you use this.$refs[“specialForm”].resetFields(); to reset the form, it reports an error:

Solution:
Wrap a div outside el-form-item and use it as an if judgment to avoid it.

Vue3.X Attribute Inheritance error [How to Solve]

When writing Vue components, the following warnings are reported inexplicably:

[Vue warn]: Extraneous non-props attributes (border, style) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
at XXXX (Location of the component where the problem occurred)
at

Solution:
The border, style property was added to the custom component and the custom component did not bother to receive it internally, hence the warning.
So, either add the properties to be received inside the component. If it is in the third party library UI library, it is recommended to remove these attributes directly.

[Solved] JS Error: cannot set property xxx of undefined

case1

Error code

quizList[index] = currentQuiz;
quizList[index].learningItem = item;

Error content

Cannot read properties of undefined (reading 'learningItem')

Error reporting reason

currentQuiz object may be undefined, if you add the property learningItem to the undefined object quizList[index] dynamically, it will cause the error “cannot set property xxx of undefined”.

Solution:

quizList[index] = currentQuiz == undefined ?{} : currentQuiz;
quizList[index].learningItem = item;

Just judge whether the quizlist [index] is undefined

 

case2

Error code

quiz.finishedstudent.forEach(item => {
	if (item.score < 80) {
		errorNum++;
	}
})

Error content

Cannot read properties of undefined (reading 'forEach')

Solution:

if (quiz.finishedstudent != undefined) {
	quiz.finishedstudent.forEach(item => {
		if (item.score < 80) {
			errorNum++;
		}
	})
}

Chrome Broswer V98 Can not manually add cookies locally, refresh cannot be retained, and the cookie item is red

Solution for Chrome 91 after SameSite by default cookies were removed, solution for cross-domain POST requests in Chrome that can’t carry cookies

Yesterday after work to start the project, Google Chrome automatically upgraded to version 98, because the previous project is required to manually add a cookie in the local development debugging, now it is impossible to manually add a cookie, and the high version removed SameSite by default cookies, resulting in the previous method can not be used, manually set after the cookie also reported red, as follows:

Now just open Chrome and visit the address chrome://flags/ and search for Partitioned cookies and change the setting to Enabled, restart the browser, manually adding cookies will be retained and will not b

npm ERR code ELIFECYCLE [How to Solve]

npm ERR! Code elifecycle solution

1. Problems

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: webpack --config config/webpack. config. js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.

The reason for this is the webpack.config.js configuration error, which is actually a path configuration error. Some path configurations in webpack.config.js are configured according to the package.json file location, and some are configured according to the current file location, and people tend to get confused when configuring them.

2. Solutions
2.1 Solution 1
Fill in the correct path, this problem is often caused by the path configuration error. Refer to the following template, I will decipher the path configuration.

entry:’. /src/js/index.js’ // this path is based on the package.json file as the base file path (not the webpack.config.js file)

template in plugins: ‘src/index.html’ //this is also based on the package.json file as the base file path

and path:path.resolve(__dirname,’…/dist’) // is based on the webpack.config.js file path

const path=require(‘path’); // call the path in node.js
const HtmlWebpackPlugin = require(‘html-webpack-plugin’);
module.exports={undefined
entry:’. /src/js/index.js’, // the file to be packaged (this path is written according to the package.json location)
output:{undefined
filename:’bundle.js’, //the name of the package file
path:path.resolve(__dirname,’…/dist’) //specify the generated file directory (written by the current file location)
},
module: {undefined
rules: [
{undefined
test: /.css$/,
use: [ ‘style-loader’, ‘css-loader’ ]
}
]
},
plugins: [
new HtmlWebpackPlugin({undefined
template: ‘src/index.html’ //configure html template (by package.json location)
})
]
}

2.2 Solution 2
Direct reinstallation, but personally do not recommend, indeed some files reinstallation is possible to solve the problem, but sometimes reinstallation is very slow, which is annoying. Reinstallation steps are as follows.

(Do not delete package.json, delete package-lock.json)

npm cache clean --force
rm -rf node_modules
rm -rf package-lock.json
npm install

How to Fix Taro SwipeAction Not Working Issue

Invalid reason:

Because two attributes of the official document are not written, and we have not written them, it will not take effect
1 The maximum sliding distance of maxdistance slider is generally the number of buttons multiplied by the button width
2 Areawidth component width (if no reference causes the component occupancy width to be 0, the page will not be displayed)

be careful:

Here, the width in option must use PX, if you use rpx, there will be UI problems on different devices, maxDistance= the width length of two options, maxDistance is the type of number

Correct code:

<AtSwipeAction
  maxDistance={140} // Button width * number of buttons
  areaWidth={Taro.getSystemInfoSync().windowWidth * 1} //Dynamically get the width of different devices
  autoClose //click the button to close it automatically
  onClick={(option, btnIndex) => { }} //Click to cancel Triggered after deleting the button, one parameter is the currently clicked option item, the second parameter is the index of the button 0 1
  options={[
    {
      text: 'cancel',
      style: {
        justifyContent: 'center',
        width: '70px',
        padding: 0,
      }
    },
    {
      text: 'Delete',
      style: {
        justifyContent: 'center',
        width: '70px',
        padding: 0,
      }
    }
  ]}>
  <View>
    Content
  </View>
</AtSwipeAction>

Postman Error: Could not send request [How to Solve]

Error reporting:

Solution: enable agent and select the available agent
setting – proxy – use postman desktop agent – Bowser agent



In addition:
if the selected agent is available, there will be a green tick about agent selection in the lower right corner. Here the Bowser agent is available:

if the selected agent is not available, it will turn into a red exclamation mark and prompt at send that the agent is not available:
Desktop agent is not available here:

[Fixed] Chrome Browser Cannot Edit Cookies Issue

I accidentally found that chrome can’t add cookies by itself. After adding cookies, it won’t be refreshed.

reason

The latest Chrome browser version has been automatically blocking this function.

Solution:

Open chrome://flags/ , search cookies , find partitioned cookies , select enabled
and then click relaunch in the lower right corner. The browser will restart automatically and take effect!

Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)

When importing the element ui, you need to introduce the corresponding component in element.js if you choose on-demand import.

import { ElForm } from 'element-plus'
import { ElButton } from 'element-plus'
import { ElFormItem } from 'element-plus'
import { ElInput } from 'element-plus'
import lang from 'element-plus/lib/locale/lang/zh-cn'
import locale from 'element-plus/lib/locale'

export default (app) => {
  locale.use(lang)
  app.use(ElButton)
  app.use(ElForm)
  app.use(ElFormItem)
  app.use(ElInput)
}

The page can be displayed normally

How to Solve Webpack CacheGroups Error

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.optimization.splitChunks has an unknown property 'CacheGroups'. These properties are valid:
   object { automaticNameDelimiter?, cacheGroups?, chunks?, defaultSizeTypes?, enforceSizeThreshold?, fallbackCacheGroup?, filename?, hidePathInfo?, maxAsyncRequests?, maxAsyncSize?, maxInitialRequests?, maxInitialSize?, maxSize?, minChunks?, minRemainingSize?, minSize?, minSizeReduction?, name?, usedExports?}
   -> Options object for splitting chunks into smaller chunks.

Previous version:

  CacheGroups:{
                vendor:{
                    test:/[\\/]node_modules[\\/]/,
                    name:'vendors',
                    chunks:'all'
                }
            }

The solution is to reduce the version or follow the new writing method

New writing:

cacheGroups: {
                commons: {
                  test: /[\\/]node_modules[\\/]/,
                  name: 'vendors',
                  chunks: 'all',
                },
              },

Node Kubelet Error: node “xxxxx“ not found [How to Solve]

11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.108952     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.209293     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.310543     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.411121     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.511949     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.612822     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.713249     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.781263     974 controller.go:144] failed to ensure lease exists, will retry in 7s, error: leases.coordination.k8s.io "localhost.localdomain" is forbidden: User "system:node:k8s222" cannot get resource "leases" in API group "coordination.k8s.io" in the namespace "kube-node-lease": can only access node lease with the same name as the requesting node
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.813355     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"
11月 05 10:58:35 localhost.localdomain kubelet[974]: E1105 10:58:35.913495     974 kubelet.go:2412] "Error getting node" err="node "localhost.localdomain" not found"

1.1 this node is always notready

[root@crust-m01 ~]# kubectl get node
NAME        STATUS     ROLES                  AGE   VERSION
k8s220   NotReady   control-plane,master   44d   v1.21.3
k8s221   NotReady   <none>                 44d   v1.21.3
k8s222   NotReady   <none>                 44d   v1.21.3

1.2 view details of this node

[root@localhost ~]# kubectl describe node k8s221


……
Unschedulable:      false
Lease:
  HolderIdentity:  k8s221
  AcquireTime:     <unset>
  RenewTime:       Tue, 28 Sep 2021 14:37:08 +0800
Conditions:
  Type             Status    LastHeartbeatTime                 LastTransitionTime                Reason              Message
  ----             ------    -----------------                 ------------------                ------              -------
  MemoryPressure   Unknown   Tue, 28 Sep 2021 14:32:16 +0800   Tue, 28 Sep 2021 14:38:17 +0800   NodeStatusUnknown   Kubelet stopped posting node status.
  DiskPressure     Unknown   Tue, 28 Sep 2021 14:32:16 +0800   Tue, 28 Sep 2021 14:38:17 +0800   NodeStatusUnknown   Kubelet stopped posting node status.
  PIDPressure      Unknown   Tue, 28 Sep 2021 14:32:16 +0800   Tue, 28 Sep 2021 14:38:17 +0800   NodeStatusUnknown   Kubelet stopped posting node status.
  Ready            Unknown   Tue, 28 Sep 2021 14:32:16 +0800   Tue, 28 Sep 2021 14:38:17 +0800   NodeStatusUnknown   Kubelet stopped posting node status.
……

1.3 view kubelet logs on this node

[root@crust-m2 ~]# service kubelet status -l
Redirecting to /bin/systemctl status  -l kubelet.service
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since 二 2021-09-28 14:51:57 CST; 4min 6s ago
     Docs: https://kubernetes.io/docs/
 Main PID: 21165 (kubelet)
    Tasks: 19
   Memory: 43.0M
   CGroup: /system.slice/kubelet.service
           └─21165 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.4.1

9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.119645   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.220694   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.321635   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.385100   21165 eviction_manager.go:255] "Eviction manager: failed to get summary stats" err="failed to get node info: node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.422387   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.523341   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.624021   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.724418   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.825475   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"
9月 28 14:56:03 crust-m2 kubelet[21165]: E0928 14:56:03.926199   21165 kubelet.go:2291] "Error getting node" err="node "crust-m2" not found"

2. [troubleshooting]

The startup command of log output in 1.3 is as follows:

/usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.4.1

 

There is no problem viewing and analyzing all configuration files in the startup command

The error err = "node" localhost. Output in 1.3 was found localdomain "Not found
the information of kubectl get node on the master is k8s220, k8s221, k8s222

conclusion
when kubernetes was installed before, the name of the master was k8s220, and the node was k8s221, k8s222, because /etc/hostname was written as localhost.localdomain by default, kubelet has always been report errors

3. [modification]

Modify the hostname file, execute the hostname command, modify the server name,

Restart kubelete