vue-page-editor页面编辑器使用文档

71 阅读1分钟

NPM地址

一、安装

使用npm:

$ npm install vue-page-editor

使用yarn:

$ yarn add vue-page-editor

安装完成后, 使用import引入:

import VuePageEditor from 'vue-page-editor';

二、当前有两种模式可以使用。

1: 编辑器模式、2:预览模式

当前编辑与预览时耦合的, 后续将进行拆分,以区分编辑与预览。

{
  EDITOR: 1,
  PREVIEW: 2 
}

1.编辑模式

编辑模式案例

<template>
  <VuePageEditor
    :editorType="1"
    :options="options"
    @preview="handlePreview"
  />
</template>

<script setup>
import VuePageEditor from 'vue-page-editor';

const options = {
  // baseURL: 'http://xx.xxx.xx.xxx', // Internal interface request address IP or Domain
  tools: 'back preview save', // Available toolbar
  customStyle: {
    // Custom style
  }
};
const handlePreview = (config) => {
  // Configuration data
  console.log(config);
};
</script>

2.预览模式

预览模式案例

<template>
  <VuePageEditor
    :editor-type="2"
    :page-info="config"
  />
</template>

<script setup>
import { ref } from 'vue';
import VuePageEditor from 'vue-page-editor';

// Configuration data created through the editor
const config = ref({});

const options = {
  // baseURL: 'http://xx.xxx.xx.xxx', // Internal interface request address IP or Domain
  tools: 'back preview save', // Available toolbar
  customStyle: {
    // Custom style
  }
};
</script>

vue-page-editor 参数

参数名称描述类型可接受值默认值
editor-type编辑器类型。1为编辑器 2为预览number1 / 21
options可配置参数,详情见下表options配置object
page-info通过编辑器创建的配置数据object
page-id通过Qm管理后台获取的页面idstring

vue-page-editor 事件

事件名描述参数
save用户点击保存config
preview用户点击预览config
back用户点击返回-

vue-page-editor 方法

方法名描述参数
--

vue-page-editor 插槽

插槽名描述-
--

options

参数名描述类型可接受值默认
baseURLIP地址或者域名stringip / domainhttp://localhost:3002/
tools工具栏可选按钮包括保存、预览、返回等stringback preview save
customStyle自定义样式object