本节将介绍如何在项目中使用 FormMaking V3。

用法

完整引入

  1. import { createApp } from 'vue'
  2. import ElementPlus from 'element-plus'
  3. import 'element-plus/dist/index.css'
  4. import FormMakingV3 from '@/form-making-v3'
  5. import '@/form-making-v3/dist/index.css'
  6. import App from './App.vue'
  7. createApp(App).use(ElementPlus).use(FormMakingV3).mount('#app')

引入部分组件

  1. import { createApp } from 'vue'
  2. import ElementPlus from 'element-plus'
  3. import 'element-plus/dist/index.css'
  4. import {
  5. MakingForm,
  6. GenerateForm
  7. } from '@/form-making-v3'
  8. import '@/form-making-v3/dist/index.css'
  9. import App from './App.vue'
  10. const app = createApp(App)
  11. app.use(ElementPlus)
  12. app.use(MakingForm)
  13. app.use(GenerateForm)
  14. app.mount('#app')

开始使用

  1. <template>
  2. <fm-making-form
  3. ref="makingform"
  4. style="height: 500px;"
  5. preview
  6. generate-code
  7. generate-json
  8. >
  9. </fm-making-form>
  10. </template>

使用时需要设置设计器的高度,默认情况高度是根据父元素 100% 来渲染。

在 Html 中使用

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <!-- 引入样式 -->
  6. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-plus/dist/index.css">
  7. <link rel="stylesheet" href="form-making-v3/dist/index.css">
  8. <style>
  9. html,body,#app{
  10. height: 100%;
  11. }
  12. </style>
  13. </head>
  14. <body >
  15. <div id="app" >
  16. <fm-making-form preview generate-code generate-json>
  17. </fm-making-form>
  18. </div>
  19. </body>
  20. <!-- 引入组件库 -->
  21. <script src="https://cdn.jsdelivr.net/npm/vue@next/dist/vue.global.prod.js"></script>
  22. <script src="https://cdn.jsdelivr.net/npm/element-plus"></script>
  23. <script src="form-making-v3/dist/form-making-v3.umd.js"></script>
  24. <script>
  25. Vue.createApp({}).use(ElementPlus).use(FormMakingV3).mount('#app')
  26. </script>
  27. </html>