当我调用 webkit_web_view_load_string() 将 html 内容加载到 webkitview 时,webkit 总是拒绝加载 html 内容中引用的本地文件或资源(css、javascript、图像)。
注意:我正在使用 GResource 将资源加载到二进制文件中?这是一个例子:
GBytes *data;
GResource *resource;
GByteArray* gbarray; resource = one_file_get_resource();
.
. . .
g_resources_register (resource);
data = g_resource_lookup_data (resource,"/com/test/resources/index.html", G_RESOURCE_LOOKUP_FLAGS_NONE,NULL);
gbarray = g_bytes_unref_to_array(data);
const gchar* data_char = gbarray->data;
. . .
webkit_web_view_load_string(webView, data_char, NULL, NULL,"");
这是我的 GResources xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/test">
<file>resources/index.html</file>
<file>resources/style.css</file>
</gresource>
</gresources>
现在我的问题是 index.html 已加载但没有 css 文件。我得到了没有样式的html文件!我该如何解决这个问题,谢谢?!