uni-app: Uncaught TypeError: Cannot read property 'createElement' of undefined The mobile terminal debugging base white screen error problem

After the cloud is packaged, it is also a white screen! !

 After packaging here, after installing and starting on the mobile phone, the same white screen and no error report can be seen! ! You can see an error report after debugging and running on the mobile phone emulator base, so it is recommended to use the mobile phone emulator base to debug! ! !

Mobile phone emulator dock debugging:

Turn on USB debugging after the developer option is turned on on the phone:

The developer option here is because each phone model has different ways to open it, just check how to open the developer option of your phone model

You only need to turn on USB debugging. Other defaults don’t matter.

Use the mobile phone USB to connect to the computer to run the mobile phone emulator App base:

To refresh run:

Error after running:

exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Uncaught TypeError: Cannot read property 'createElement' of undefined

createElement finds the referenced external js file in the file search here:

 Because createElement can only be used in H5, not in app! ! !

You can only add if to judge

// #ifdef H5
     *****js代码块*****
// #endif

It looks like this:

But if this is the case, js will not be used, and this vegetable chicken is also very uncomfortable. My gods, let’s think of another way.

Here we are talking about when running on the mobile terminal

Pay attention to the official documentation here:


https://uniapp.dcloud.net.cn/matter.htmlhttps://uniapp.dcloud.net.cn/matter.html

 Probably looks like this:


<template>

</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				
			}
		},
		onLoad() {
				
		},
		created() {

		},
		mounted() {

		},
		// 方法
		methods: {
				

		}
</script>

<script module="test" lang="renderjs">
	export default {
		mounted() {
			
		},
		methods: {
			
		}
	}
</script>

<style>
	@import"@/style/css/login/login.css";
</style>

That is to say, there must be two scripts on the page, one is marked with renderjs

My understanding is that the process of executing the script with renderjs on the mobile terminal should be to compile the code into something that can be recognized on the mobile phone

Probably the compilation and execution process of the page looks like this:

 Renderjs usage reference article:

https://uniapp.dcloud.net.cn/tutorial/renderjs.htmlhttps://uniapp.dcloud.net.cn/tutorial/renderjs.html

https://juejin.cn/post/7049185827582115870https://juejin.cn/post/7049185827582115870

The white screen at runtime is not only due to the problem of rendersjs, the grammatical rule error will also cause an error to report a white screen. Be careful not to spend half a day after changing the code and still have a white screen. It turns out that it is not the problem here at all. uncomfortable

Guess you like

Origin blog.csdn.net/qq_45609680/article/details/129446548