我try 将本地.html
文件加载到React Native中的WebView
:
// load local .html file
const PolicyHTML = require('./Policy.html');
// PolicyHTML is just a number of `1`
console.log('PolicyHTML:', PolicyHTML);
// will cause an error: JSON value '1' of type NSNumber cannot be converted to NSString
<WebView html={PolicyHTML} />
.html
文件应该作为字符串读取,而不是作为资源代表读取.
如何在React Native中将.html
文件加载到WebView
中?
顺便问一下,require()
人中的资源代表是什么类型的?是number
吗?