亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Umi4集成阿里低代碼框架lowcode-engine實(shí)現(xiàn)

 更新時(shí)間:2022年08月12日 11:28:42   作者:杰出D  
這篇文章主要為大家介紹了Umi4集成阿里低代碼框架lowcode-engine實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

前言

最近準(zhǔn)備研究下阿里低代碼框架lowcode-engine, 官方Demo是提供好的腳手架,由于我們的框架使用的是umi,官方文檔提供了一些教程,在此記錄下在umi4集成lowcode-engine.

實(shí)現(xiàn)

搭建umi4項(xiàng)目

1.通過官方文檔的快速開始,我們可以快速創(chuàng)建出項(xiàng)目

先找個(gè)地方建個(gè)空目錄

mkdir myapp && cd myapp

通過官方工具創(chuàng)建項(xiàng)目, 這里我們采用pnpm包管理工具

$ pnpm dlx create-umi@latest
? Install the following package: create-umi? (Y/n) · true
? Pick Npm Client ? pnpm
? Pick Npm Registry ? taobao
Write: .gitignore
Write: .npmrc
Write: .umirc.ts
Copy:  layouts/index.tsx
Write: package.json
Copy:  pages/index.tsx
Copy:  pages/users.tsx
Copy:  pages/users/foo.tsx
> @ postinstall /private/tmp/sorrycc-vylwuW
> umi setup
info  - generate files

創(chuàng)建完成后,安裝依賴, 執(zhí)行 pnpm dev就可以看到我們的項(xiàng)目啟動(dòng)起來了。

集成lowcode-engine

  • 引入U(xiǎn)MD包, 我們?cè)?.umirc.ts中配置externals,styles和scripts
 externals: {
    'react': 'var window.React',
    'react-dom': 'var window.ReactDOM',
    'prop-types': 'var window.PropTypes',
    '@alifd/next': 'var window.Next',
    '@alilc/lowcode-engine': 'var window.AliLowCodeEngine',
    '@alilc/lowcode-editor-core': 'var window.AliLowCodeEngine.common.editorCabin',
    '@alilc/lowcode-editor-skeleton': 'var window.AliLowCodeEngine.common.skeletonCabin',
    '@alilc/lowcode-designer': 'var window.AliLowCodeEngine.common.designerCabin',
    '@alilc/lowcode-engine-ext': 'var window.AliLowCodeEngineExt',
    '@ali/lowcode-engine': 'var window.AliLowCodeEngine',
    'moment': 'var window.moment',
    'lodash': 'var window._',
  },
  styles: [
    'https://alifd.alicdn.com/npm/@alilc/lowcode-engine@latest/dist/css/engine-core.css',
    'https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.css',
    'https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light/0.2.0/next.min.css',
    'https://alifd.alicdn.com/npm/@alilc/lowcode-engine-ext@latest/dist/css/engine-ext.css'
  ],
  scripts: [
    {
      src: 'https://g.alicdn.com/code/lib/react/18.0.0/umd/react.development.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/code/lib/react-dom/18.0.0/umd/react-dom.development.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/code/lib/moment.js/2.29.1/moment-with-locales.min.js',
      defer: false,
    },
    {
      src: 'https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js',
      defer: false,
    },
    {
      src: 'https://alifd.alicdn.com/npm/@alilc/lowcode-engine@latest/dist/js/engine-core.js',
      defer: false,
    },
    {
      src: 'https://alifd.alicdn.com/npm/@alilc/lowcode-engine-ext@latest/dist/js/engine-ext.js',
      defer: false,
    }
  • 我們使用lowcode-enginey引擎提供的init進(jìn)行初始化,init() 內(nèi)部會(huì)調(diào)用 ReactDOM.render() 函數(shù),這樣初始化有些弊端。一些內(nèi)容沒有辦法與外部的 React 組件進(jìn)行通信,也就沒有辦法在一些自定義的 plugin 中獲取 redux 上的全局?jǐn)?shù)據(jù)等內(nèi)容,但也有好處,就是低代碼引擎比較獨(dú)立,后期可以拆出供多個(gè)項(xiàng)目使用。

我們參考官方提供的Demo的入口文件。在我們這里封裝成一個(gè)LowcodeEditor組件。

import { init, plugins } from '@alilc/lowcode-engine';
import { useEffect } from 'react';
import registerPlugins from './plugin';
import './global.less';
export default function LowcodeEditor() {
  useEffect(() => {
    const preference = new Map();
    preference.set('DataSourcePane', {
      importPlugins: [],
      dataSourceTypes: [
        {
          type: 'fetch',
        },
        {
          type: 'jsonp',
        },
      ],
    });
    (async function main() {
      await registerPlugins();
      console.log('first-2')
      init(
        document.getElementById('engine-container')!, {
          // designMode: 'live',
          // locale: 'zh-CN',
          enableCondition: true,
          enableCanvasLock: true,
          // 默認(rèn)綁定變量
          supportVariableGlobally: true,
          // simulatorUrl 在當(dāng) engine-core.js 同一個(gè)父路徑下時(shí)是不需要配置的?。?!
          // 這里因?yàn)橛玫氖?alifd cdn,在不同 npm 包,engine-core.js 和 react-simulator-renderer.js 是不同路徑
          simulatorUrl: [
            'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/css/react-simulator-renderer.css',
            'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js',
          ],
          requestHandlersMap: {
            fetch: async () => {}
          }
        },
        preference,
      );
    })();
  }, []);
  return <div id='engine-container' style={{backgroundColor: 'red'}}></div>;
}

這里只是入口組件的初始化,組件內(nèi)部還有很多內(nèi)容,我們重Deom中copy出來。比如plugin,assets.josn,schem.json等,這里不做過多的介紹,里面的內(nèi)容好多,后續(xù)我們一邊學(xué)習(xí),一邊慢慢拆解,分享。

  • 使用LowcodeEditor組件,在我們需要的地方直接導(dǎo)入,使用就行
import yayJpg from '../assets/yay.jpg';
import LowcodeEditor from '@/components/lowcode-editor2';
export default function HomePage() {
  return (
    <div style={{height: '100%'}}>
      <LowcodeEditor />
    </div>
  );
}

4.訪問頁面

結(jié)束語

代碼已上傳到github,請(qǐng)查看mi4-lowcode-app。

以上就是Umi4集成阿里低代碼框架lowcode-engine實(shí)現(xiàn)的詳細(xì)內(nèi)容,更多關(guān)于Umi4集成lowcode-engine的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 微信小程序 時(shí)間格式化(util.formatTime(new Date))詳解

    微信小程序 時(shí)間格式化(util.formatTime(new Date))詳解

    這篇文章主要介紹了微信小程序 時(shí)間格式化(util.formatTime(new Date))詳解的相關(guān)資料,這里附實(shí)例,一目了然很容易解決,需要的朋友可以參考下
    2016-11-11
  • 圖片按比例縮放函數(shù)

    圖片按比例縮放函數(shù)

    圖片按比例縮放函數(shù)...
    2006-06-06
  • tagName的使用,留一筆

    tagName的使用,留一筆

    tagName的使用,留一筆...
    2006-06-06
  • 手寫實(shí)現(xiàn)JS中的new

    手寫實(shí)現(xiàn)JS中的new

    這篇文章主要介紹JS中的new,new 運(yùn)算符創(chuàng)建一個(gè)用戶定義的對(duì)象類型的實(shí)例或具有構(gòu)造函數(shù)的內(nèi)置對(duì)象的實(shí)例。下面我們一起來看看我呢很臟具體內(nèi)容的詳細(xì)介紹,需要的朋友可以參考一下
    2021-11-11
  • JavaScript實(shí)現(xiàn)余額數(shù)字滾動(dòng)效果

    JavaScript實(shí)現(xiàn)余額數(shù)字滾動(dòng)效果

    這篇文章主要介紹了JavaScript實(shí)現(xiàn)余額數(shù)字滾動(dòng)效果,將傳入的帶滾動(dòng)的n位數(shù)字拆分成每一個(gè)要滾動(dòng)的數(shù),然后動(dòng)態(tài)的創(chuàng)建裝著滾動(dòng)到每一位相應(yīng)數(shù)字的容器,然后放入傳入的目標(biāo)容器中,更多詳細(xì)內(nèi)容,一起進(jìn)入下面文章學(xué)習(xí)吧
    2021-12-12
  • JS 里為什么會(huì)有 this

    JS 里為什么會(huì)有 this

    這篇文章主要介紹了JS 里為什么會(huì)有 this,文章主要從語言創(chuàng)造者(JS 之父的角度)來思考 this,我之前那篇講 this 的文章是從使用者的角度寫的,需要的朋友可以參考一下
    2021-10-10
  • JavaScript實(shí)現(xiàn)一個(gè)Promise隊(duì)列小工具

    JavaScript實(shí)現(xiàn)一個(gè)Promise隊(duì)列小工具

    這篇文章主要介紹了JavaScript實(shí)現(xiàn)一個(gè)Promise隊(duì)列小工具,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-08-08
  • jQuery單頁面文字搜索插件jquery.fullsearch.js的使用方法

    jQuery單頁面文字搜索插件jquery.fullsearch.js的使用方法

    jquery.fullsearch.js是一款基于Bootstrap文字搜索插件,可以幫助您快速搜索到當(dāng)前頁面所包含的指定文字,并定位到所在位置
    2020-02-02
  • TS?項(xiàng)目中高效處理接口返回?cái)?shù)據(jù)方法詳解

    TS?項(xiàng)目中高效處理接口返回?cái)?shù)據(jù)方法詳解

    這篇文章主要為大家介紹了TS?項(xiàng)目中如何高效的處理接口返回的數(shù)據(jù)的方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • JavaScript取消請(qǐng)求方法

    JavaScript取消請(qǐng)求方法

    這篇文章主要為大家介紹了JavaScript取消請(qǐng)求方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07

最新評(píng)論