Solution to layui error: first open the corresponding layui file; then press the control mouse to click on the object or method to track the source of the error; finally, reintroduce "layui.js" under the "static/lib/layui" package "That's it.
Recommended: "layUI Tutorial"
1. Question
is as titled layerUI During use, an error message is reported that layer is not defined, as shown in Figure 2. Problem understanding
To solve the problem, we first look at the error report. The error says that layer is not defined, and the error is pointed out in x-layui.js line 22 and stationsstatistics line 70
Then we open these two files as shown:
Yes, the onclick click event of the page reports an error, and It’s at line 22 of x-layui.js
In fact, at this point, people who are keen on solving problems can probably guess that the problem is caused by a certain file not being introduced or being introduced incorrectly. Next, I will also Baidu There were some problems, and they probably all said that a certain file was not imported, and then it was solved after importing it. However, as shown in the picture above, I introduced layui.js (line 80 in the picture above), but my problem is still unresolved.
3. Problem Solving
So how did I solve it. I think since the error reported is layer is not defined, then I will go to the line where the error was reported. Idea has a tracking function, that is, pressing the control mouse and clicking on the object or method can track its source, as shown below
Here it means that layer comes from layui.all.js under the static/lib/layui package or layer.js under the static/lib/layui/lay/modules package
Then I introduced static/lib /layui.js under the package, no wonder it reports an error
As shown below, change it to idea tracking, clear the cache, and no longer report an error
- -------------------------------------------------- ------------------------conclusion of issue------------------------ -------------------------------------------------- ----------
Actually, I'm not very familiar with the front-end, and this is my first time using layui. And other pages also have this function. Layui.js under the static/lib/layui package is introduced. There is no problem, which is really strange.
I am just talking about ideas and methods for solving problems here. After all, everyone encounters different situations. Others’ problems may not be able to help you, so you can only solve them yourself.
There are a few points to note: 1. Read the error report carefully 2. Analyze with the help of tools 3. Remember to clear the browser cache after making changes!
The above is the detailed content of How to solve layui error reporting problem. For more information, please follow other related articles on the PHP Chinese website!