Javascript 将远程html文件加载到grapesjs中
能够获取我的远程HTML文件使用加载URL和获取状态确定,我如何才能加载这个获取HTML和CSS到编辑器?目前我在编辑器中得到了一个空白屏幕 到目前为止,我尝试的是:Javascript 将远程html文件加载到grapesjs中,javascript,php,grapesjs,Javascript,Php,Grapesjs,能够获取我的远程HTML文件使用加载URL和获取状态确定,我如何才能加载这个获取HTML和CSS到编辑器?目前我在编辑器中得到了一个空白屏幕 到目前为止,我尝试的是: storageManager: { type: 'remote', autosave: false, autoload: true, contentTypeJson: false, setStepsBeforeSave: 1, contentTypeJson: true, p
storageManager: {
type: 'remote',
autosave: false,
autoload: true,
contentTypeJson: false,
setStepsBeforeSave: 1,
contentTypeJson: true,
params: {
},
storeComponents: true,
storeStyles: true,
storeHtml: true,
storeCss: true,
urlStore: '../inc/page/edit_builder.php?id=<?php echo $pid; ?>',
urlLoad: '../inc/page/fetch_builder.php?id=<?php echo $pid; ?>',
headers: {
'Content-Type': 'application/json'
},
json_encode:{
"gjs-html": [],
"gjs-css": [],
}
//headers: { Authorization: 'Basic ...' },
}
editor.load(res => console.log('Load callback'));
您需要将远程HTML/CSS传递给GrapesJs编辑器。 在javascript中
editor.setStyle(Your remote style file)
editor.setComponent(Your remote HTML)
[重要]
GrapesJS可以从任何HTML/CSS开始,但使用
这种方法只用于导入已经存在的HTML模板一次
用户开始编辑,始终依赖JSON对象,因为HTML
不包含有关组件的信息
签出此链接。用于存储和加载模板
editor.setStyle(Your remote style file)
editor.setComponent(Your remote HTML)