最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

采用React編寫(xiě)小程序的Remax框架的編譯流程解析(推薦)

 更新時(shí)間:2021年04月22日 09:21:16   作者:我的小樹(shù)林  
這篇文章主要介紹了采用React編寫(xiě)小程序的Remax框架的編譯流程解析(推薦),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

Remax是螞蟻開(kāi)源的一個(gè)用React來(lái)開(kāi)發(fā)小程序的框架,采用運(yùn)行時(shí)無(wú)語(yǔ)法限制的方案。整體研究下來(lái)主要分為三大部分:運(yùn)行時(shí)原理、模板渲染原理、編譯流程;看了下現(xiàn)有大部分文章主要集中在Reamx的運(yùn)行時(shí)和模板渲染原理上,而對(duì)整個(gè)React代碼編譯為小程序的流程介紹目前還沒(méi)有看到,本文即是來(lái)補(bǔ)充這個(gè)空白。
關(guān)于模板渲染原理看這篇文章:http://m.fzitv.net/article/132635.htm
關(guān)于remax運(yùn)行時(shí)原理看這篇文章:http://m.fzitv.net/article/210293.htm
關(guān)于React自定義渲染器看這篇文章:http://m.fzitv.net/article/198425.htm

Remax的基本結(jié)構(gòu):

1、remax-runtime 運(yùn)行時(shí),提供自定義渲染器、宿主組件的包裝、以及由React組件到小程序的App、Page、Component的配置生成器

// 自定義渲染器
export { default as render } from './render';
// 由app.js到小程序App構(gòu)造器的配置處理
export { default as createAppConfig } from './createAppConfig';
// 由React到小程序Page頁(yè)面構(gòu)造器的一系列適配處理
export { default as createPageConfig } from './createPageConfig';
// 由React組件到小程序自定義組件Component構(gòu)造器的一系列適配處理
export { default as createComponentConfig } from './createComponentConfig';
// 
export { default as createNativeComponent } from './createNativeComponent';
// 生成宿主組件,比如小程序原生提供的View、Button、Canvas等
export { default as createHostComponent } from './createHostComponent';
export { createPortal } from './ReactPortal';
export { RuntimeOptions, PluginDriver } from '@remax/framework-shared';
export * from './hooks';

import { ReactReconcilerInst } from './render';
export const unstable_batchedUpdates = ReactReconcilerInst.batchedUpdates;

export default {
  unstable_batchedUpdates,
};

2、remax-wechat 小程序相關(guān)適配器
template模板相關(guān),與模板相關(guān)的處理原則及原理可以看這個(gè)http://m.fzitv.net/article/145552.htm
templates // 與渲染相關(guān)的模板
src/api 適配與微信小程序相關(guān)的各種全局api,有的進(jìn)行了promisify化

import { promisify } from '@remax/framework-shared';

declare const wx: WechatMiniprogram.Wx;

export const canIUse = wx.canIUse;
export const base64ToArrayBuffer = wx.base64ToArrayBuffer;
export const arrayBufferToBase64 = wx.arrayBufferToBase64;
export const getSystemInfoSync = wx.getSystemInfoSync;
export const getSystemInfo = promisify(wx.getSystemInfo);

src/types/config.ts 與小程序的Page、App相關(guān)配置內(nèi)容的適配處理

/** 頁(yè)面配置文件 */
// reference: https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/page.html
export interface PageConfig {
  /**
   * 默認(rèn)值:#000000
   * 導(dǎo)航欄背景顏色,如 #000000
   */
  navigationBarBackgroundColor?: string;
  /**
   * 默認(rèn)值:white
   * 導(dǎo)航欄標(biāo)題顏色,僅支持 black / white
   */
  navigationBarTextStyle?: 'black' | 'white';
  
  /** 全局配置文件 */
// reference: https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html
export interface AppConfig {
  /**
   * 頁(yè)面路徑列表
   */
  pages: string[];
  /**
   * 全局的默認(rèn)窗口表現(xiàn)
   */
  window?: {
    /**
     * 默認(rèn)值:#000000
     * 導(dǎo)航欄背景顏色,如 #000000
     */
    navigationBarBackgroundColor?: string;
    /**
     * 默認(rèn)值: white
     * 導(dǎo)航欄標(biāo)題顏色,僅支持 black / white
     */
    navigationBarTextStyle?: 'white' | 'black';

src/types/component.ts 微信內(nèi)置組件相關(guān)的公共屬性、事件等屬性適配

import * as React from 'react';

/** 微信內(nèi)置組件公共屬性 */
// reference: https://developers.weixin.qq.com/miniprogram/dev/framework/view/component.html
export interface BaseProps {
  /** 自定義屬性: 組件上觸發(fā)的事件時(shí),會(huì)發(fā)送給事件處理函數(shù) */
  readonly dataset?: DOMStringMap;
  /** 組件的唯一標(biāo)示: 保持整個(gè)頁(yè)面唯一 */
  id?: string;
  /** 組件的樣式類: 在對(duì)應(yīng)的 WXSS 中定義的樣式類 */
  className?: string;
  /** 組件的內(nèi)聯(lián)樣式: 可以動(dòng)態(tài)設(shè)置的內(nèi)聯(lián)樣式 */
  style?: React.CSSProperties;
  /** 組件是否顯示: 所有組件默認(rèn)顯示 */
  hidden?: boolean;
  /** 動(dòng)畫(huà)對(duì)象: 由`wx.createAnimation`創(chuàng)建 */
  animation?: Array<Record<string, any>>;

  // reference: https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html
  /** 點(diǎn)擊時(shí)觸發(fā) */
  onTap?: (event: TouchEvent) => void;
  /** 點(diǎn)擊時(shí)觸發(fā) */
  onClick?: (event: TouchEvent) => void;
  /** 手指觸摸動(dòng)作開(kāi)始 */
  onTouchStart?: (event: TouchEvent) => void;

src/hostComponents 針對(duì)微信小程序宿主組件的包裝和適配;node.ts是將小程序相關(guān)屬性適配到React的規(guī)范

export const alias = {
  id: 'id',
  className: 'class',
  style: 'style',
  animation: 'animation',
  src: 'src',
  loop: 'loop',
  controls: 'controls',
  poster: 'poster',
  name: 'name',
  author: 'author',
  onError: 'binderror',
  onPlay: 'bindplay',
  onPause: 'bindpause',
  onTimeUpdate: 'bindtimeupdate',
  onEnded: 'bindended',
};

export const props = Object.values(alias);

各種組件也是利用createHostComponent生成

import * as React from 'react';
import { createHostComponent } from '@remax/runtime';

// 微信已不再維護(hù)
export const Audio: React.ComponentType = createHostComponent('audio');

createHostComponent生成React的Element

import * as React from 'react';
import { RuntimeOptions } from '@remax/framework-shared';

export default function createHostComponent<P = any>(name: string, component?: React.ComponentType<P>) {
  if (component) {
    return component;
  }

  const Component = React.forwardRef((props, ref: React.Ref<any>) => {
    const { children = [] } = props;
    let element = React.createElement(name, { ...props, ref }, children);
    element = RuntimeOptions.get('pluginDriver').onCreateHostComponentElement(element) as React.DOMElement<any, any>;
    return element;
  });
  return RuntimeOptions.get('pluginDriver').onCreateHostComponent(Component);
}

3、remax-macro 按照官方描述是基于babel-plugin-macros的宏;所謂宏是在編譯時(shí)進(jìn)行字符串的靜態(tài)替換,而Javascript沒(méi)有編譯過(guò)程,babel實(shí)現(xiàn)宏的方式是在將代碼編譯為ast樹(shù)之后,對(duì)ast語(yǔ)法樹(shù)進(jìn)行操作來(lái)替換原本的代碼。詳細(xì)文章可以看這里https://zhuanlan.zhihu.com/p/64346538;
remax這里是利用macro來(lái)進(jìn)行一些宏的替換,比如useAppEvent和usePageEvent等,替換為從remax/runtime中進(jìn)行引入

import { createMacro } from 'babel-plugin-macros';


import createHostComponentMacro from './createHostComponent';
import requirePluginComponentMacro from './requirePluginComponent';
import requirePluginMacro from './requirePlugin';
import usePageEventMacro from './usePageEvent';
import useAppEventMacro from './useAppEvent';

function remax({ references, state }: { references: { [name: string]: NodePath[] }; state: any }) {
  references.createHostComponent?.forEach(path => createHostComponentMacro(path, state));

  references.requirePluginComponent?.forEach(path => requirePluginComponentMacro(path, state));

  references.requirePlugin?.forEach(path => requirePluginMacro(path));

  const importer = slash(state.file.opts.filename);

  Store.appEvents.delete(importer);
  Store.pageEvents.delete(importer);

  references.useAppEvent?.forEach(path => useAppEventMacro(path, state));

  references.usePageEvent?.forEach(path => usePageEventMacro(path, state));
}

export declare function createHostComponent<P = any>(
  name: string,
  props: Array<string | [string, string]>
): React.ComponentType<P>;

export declare function requirePluginComponent<P = any>(pluginName: string): React.ComponentType<P>;

export declare function requirePlugin<P = any>(pluginName: string): P;

export declare function usePageEvent(eventName: PageEventName, callback: (...params: any[]) => any): void;

export declare function useAppEvent(eventName: AppEventName, callback: (...params: any[]) => any): void;

export default createMacro(remax);
import * as t from '@babel/types';
import { slash } from '@remax/shared';
import { NodePath } from '@babel/traverse';
import Store from '@remax/build-store';
import insertImportDeclaration from './utils/insertImportDeclaration';

const PACKAGE_NAME = '@remax/runtime';
const FUNCTION_NAME = 'useAppEvent';

function getArguments(callExpression: NodePath<t.CallExpression>, importer: string) {
  const args = callExpression.node.arguments;
  const eventName = args[0] as t.StringLiteral;
  const callback = args[1];

  Store.appEvents.set(importer, Store.appEvents.get(importer)?.add(eventName.value) ?? new Set([eventName.value]));

  return [eventName, callback];
}

export default function useAppEvent(path: NodePath, state: any) {
  const program = state.file.path;
  const importer = slash(state.file.opts.filename);
  const functionName = insertImportDeclaration(program, FUNCTION_NAME, PACKAGE_NAME);
  const callExpression = path.findParent(p => t.isCallExpression(p)) as NodePath<t.CallExpression>;
  const [eventName, callback] = getArguments(callExpression, importer);

  callExpression.replaceWith(t.callExpression(t.identifier(functionName), [eventName, callback]));
}

個(gè)人感覺(jué)這個(gè)設(shè)計(jì)有些過(guò)于復(fù)雜,可能跟remax的設(shè)計(jì)有關(guān),在remax/runtime中,useAppEvent實(shí)際從remax-framework-shared中導(dǎo)出;
不過(guò)也倒是讓我學(xué)到了一種對(duì)代碼修改的處理方式。

4、remax-cli remax的腳手架,整個(gè)remax工程,生成到小程序的編譯流程也是在這里處理。
先來(lái)看一下一個(gè)作為Page的React文件是如何與小程序的原生Page構(gòu)造器關(guān)聯(lián)起來(lái)的。
假設(shè)原先頁(yè)面代碼是這個(gè)樣子,

import * as React from 'react';
import { View, Text, Image } from 'remax/wechat';
import styles from './index.css';

export default () => {
  return (
    <View className={styles.app}>
      <View className={styles.header}>
        <Image
          src="https://gw.alipayobjects.com/mdn/rms_b5fcc5/afts/img/A*OGyZSI087zkAAAAAAAAAAABkARQnAQ"
          className={styles.logo}
          alt="logo"
        />
        <View className={styles.text}>
          編輯 <Text className={styles.path}>src/pages/index/index.js</Text>開(kāi)始
        </View>
      </View>
    </View>
  );
};

這部分處理在remax-cli/src/build/entries/PageEntries.ts代碼中,可以看到這里是對(duì)源碼進(jìn)行了修改,引入了runtime中的createPageConfig函數(shù)來(lái)對(duì)齊React組件與小程序原生Page需要的屬性,同時(shí)調(diào)用原生的Page構(gòu)造器來(lái)實(shí)例化頁(yè)面。

import * as path from 'path';
import VirtualEntry from './VirtualEntry';

export default class PageEntry extends VirtualEntry {
  outputSource() {
    return `
      import { createPageConfig } from '@remax/runtime';
      import Entry from './${path.basename(this.filename)}';
      Page(createPageConfig(Entry, '${this.name}'));
    `;
  }
}

createPageConfig來(lái)負(fù)責(zé)將React組件掛載到remax自定義的渲染容器中,同時(shí)對(duì)小程序Page的各個(gè)生命周期與remax提供的各種hook進(jìn)行關(guān)聯(lián)

export default function createPageConfig(Page: React.ComponentType<any>, name: string) {
  const app = getApp() as any;

  const config: any = {
    data: {
      root: {
        children: [],
      },
      modalRoot: {
        children: [],
      },
    },

    wrapperRef: React.createRef<any>(),

    lifecycleCallback: {},

    onLoad(this: any, query: any) {
      const PageWrapper = createPageWrapper(Page, name);
      this.pageId = generatePageId();

      this.lifecycleCallback = {};
      this.data = { // Page中定義的data實(shí)際是remax在內(nèi)存中生成的一顆鏡像樹(shù)
        root: {
          children: [],
        },
        modalRoot: {
          children: [],
        },
      };

      this.query = query;
      // 生成自定義渲染器需要定義的容器
      this.container = new Container(this, 'root');
      this.modalContainer = new Container(this, 'modalRoot');
      // 這里生成頁(yè)面級(jí)別的React組件
      const pageElement = React.createElement(PageWrapper, {
        page: this,
        query,
        modalContainer: this.modalContainer,
        ref: this.wrapperRef,
      });

      if (app && app._mount) {
        this.element = createPortal(pageElement, this.container, this.pageId);
        app._mount(this);
      } else {
          // 調(diào)用自定義渲染器進(jìn)行渲染
        this.element = render(pageElement, this.container);
      }
      // 調(diào)用生命周期中的鉤子函數(shù)
      return this.callLifecycle(Lifecycle.load, query);
    },

    onUnload(this: any) {
      this.callLifecycle(Lifecycle.unload);
      this.unloaded = true;
      this.container.clearUpdate();
      app._unmount(this);
    },

Container是按照React自定義渲染規(guī)范定義的根容器,最終是在applyUpdate方法中調(diào)用小程序原生的setData方法來(lái)更新渲染視圖

applyUpdate() {
  if (this.stopUpdate || this.updateQueue.length === 0) {
    return;
  }

  const startTime = new Date().getTime();

  if (typeof this.context.$spliceData === 'function') {
    let $batchedUpdates = (callback: () => void) => {
      callback();
    };

    if (typeof this.context.$batchedUpdates === 'function') {
      $batchedUpdates = this.context.$batchedUpdates;
    }

    $batchedUpdates(() => {
      this.updateQueue.map((update, index) => {
        let callback = undefined;
        if (index + 1 === this.updateQueue.length) {
          callback = () => {
            nativeEffector.run();
            /* istanbul ignore next */
            if (RuntimeOptions.get('debug')) {
              console.log(`setData => 回調(diào)時(shí)間:${new Date().getTime() - startTime}ms`);
            }
          };
        }

        if (update.type === 'splice') {
          this.context.$spliceData(
            {
              [this.normalizeUpdatePath([...update.path, 'children'])]: [
                update.start,
                update.deleteCount,
                ...update.items,
              ],
            },
            callback
          );
        }

        if (update.type === 'set') {
          this.context.setData(
            {
              [this.normalizeUpdatePath([...update.path, update.name])]: update.value,
            },
            callback
          );
        }
      });
    });

    this.updateQueue = [];

    return;
  }

  const updatePayload = this.updateQueue.reduce<{ [key: string]: any }>((acc, update) => {
    if (update.node.isDeleted()) {
      return acc;
    }
    if (update.type === 'splice') {
      acc[this.normalizeUpdatePath([...update.path, 'nodes', update.id.toString()])] = update.items[0] || null;

      if (update.children) {
        acc[this.normalizeUpdatePath([...update.path, 'children'])] = (update.children || []).map(c => c.id);
      }
    } else {
      acc[this.normalizeUpdatePath([...update.path, update.name])] = update.value;
    }
    return acc;
  }, {});
  // 更新渲染視圖
  this.context.setData(updatePayload, () => {
    nativeEffector.run();
    /* istanbul ignore next */
    if (RuntimeOptions.get('debug')) {
      console.log(`setData => 回調(diào)時(shí)間:${new Date().getTime() - startTime}ms`, updatePayload);
    }
  });

  this.updateQueue = [];
}

而對(duì)于容器的更新是在render文件中的render方法進(jìn)行的,

function getPublicRootInstance(container: ReactReconciler.FiberRoot) {
  const containerFiber = container.current;
  if (!containerFiber.child) {
    return null;
  }
  return containerFiber.child.stateNode;
}

export default function render(rootElement: React.ReactElement | null, container: Container | AppContainer) {
  // Create a root Container if it doesnt exist
  if (!container._rootContainer) {
    container._rootContainer = ReactReconcilerInst.createContainer(container, false, false);
  }

  ReactReconcilerInst.updateContainer(rootElement, container._rootContainer, null, () => {
    // ignore
  });

  return getPublicRootInstance(container._rootContainer);
}

另外這里渲染的組件,其實(shí)也是經(jīng)過(guò)了createPageWrapper包裝了一層,主要是為了處理一些forward-ref相關(guān)操作。
現(xiàn)在已經(jīng)把頁(yè)面級(jí)別的React組件與小程序原生Page關(guān)聯(lián)起來(lái)了。
對(duì)于Component的處理與這個(gè)類似,可以看remax-cli/src/build/entries/ComponentEntry.ts文件

import * as path from 'path';
import VirtualEntry from './VirtualEntry';

export default class ComponentEntry extends VirtualEntry {
  outputSource() {
    return `
      import { createComponentConfig } from '@remax/runtime';
      import Entry from './${path.basename(this.filename)}';
      Component(createComponentConfig(Entry));
    `;
  }
}

那么對(duì)于普通的組件,remax會(huì)把他們編譯稱為自定義組件,小程序的自定義組件是由json wxml wxss js組成,由React組件到這些文件的處理過(guò)程在remax-cli/src/build/webpack/plugins/ComponentAsset中處理,生成wxml、wxss和js文件

export default class ComponentAssetPlugin {
  builder: Builder;
  cache: SourceCache = new SourceCache();

  constructor(builder: Builder) {
    this.builder = builder;
  }

  apply(compiler: Compiler) {
    compiler.hooks.emit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
      const { options, api } = this.builder;
      const meta = api.getMeta();

      const { entries } = this.builder.entryCollection;
      await Promise.all(
        Array.from(entries.values()).map(async component => {
          if (!(component instanceof ComponentEntry)) {
            return Promise.resolve();
          }
          const chunk = compilation.chunks.find(c => {
            return c.name === component.name;
          });
          const modules = [...getModules(chunk), component.filename];

          let templatePromise;
          if (options.turboRenders) {
            // turbo page
            templatePromise = createTurboTemplate(this.builder.api, options, component, modules, meta, compilation);
          } else {
            templatePromise = createTemplate(component, options, meta, compilation, this.cache);
          }

          await Promise.all([
            await templatePromise,
            await createManifest(this.builder, component, compilation, this.cache),
          ]);
        })
      );

      callback();
    });
  }
}

而Page的一系列文件在remax-cli/src/build/webpack/plugins/PageAsset中進(jìn)行處理,同時(shí)在createMainifest中會(huì)分析Page與自定義組件之間的依賴關(guān)系,自動(dòng)生成usingComponents的關(guān)聯(lián)關(guān)系。

到此這篇關(guān)于采用React編寫(xiě)小程序的Remax框架的編譯流程解析(推薦)的文章就介紹到這了,更多相關(guān)React編寫(xiě)小程序內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 從零開(kāi)始搭建一個(gè)react項(xiàng)目開(kāi)發(fā)

    從零開(kāi)始搭建一個(gè)react項(xiàng)目開(kāi)發(fā)

    這篇文章主要介紹了從零開(kāi)始搭建一個(gè)react項(xiàng)目開(kāi)發(fā),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • 2個(gè)奇怪的react寫(xiě)法

    2個(gè)奇怪的react寫(xiě)法

    大家好,我卡頌。雖然React官網(wǎng)用大量篇幅介紹最佳實(shí)踐,但因JSX語(yǔ)法的靈活性,所以總是會(huì)出現(xiàn)奇奇怪怪的React寫(xiě)法。本文介紹2種奇怪(但在某些場(chǎng)景下有意義)的React寫(xiě)法。也歡迎大家在評(píng)論區(qū)討論你遇到過(guò)的奇怪寫(xiě)法
    2023-03-03
  • ahooks封裝cookie?localStorage?sessionStorage方法

    ahooks封裝cookie?localStorage?sessionStorage方法

    這篇文章主要為大家介紹了ahooks封裝cookie?localStorage?sessionStorage的方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • React掌握openapi-typescript-codegen快速生成API客戶端代碼的過(guò)程

    React掌握openapi-typescript-codegen快速生成API客戶端代碼的過(guò)程

    openapi-typescript-codegen是一個(gè)開(kāi)源工具,用于根據(jù)OpenAPI規(guī)范自動(dòng)生成TypeScript代碼,包括類型定義和API客戶端代碼,它幫助開(kāi)發(fā)者節(jié)省手動(dòng)編寫(xiě)代碼的時(shí)間,提高開(kāi)發(fā)效率,感興趣的朋友一起看看吧
    2024-11-11
  • react render props模式實(shí)現(xiàn)組件復(fù)用示例

    react render props模式實(shí)現(xiàn)組件復(fù)用示例

    本文主要介紹了react render props模式實(shí)現(xiàn)組件復(fù)用示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • 如何使用React的VideoPlayer構(gòu)建視頻播放器

    如何使用React的VideoPlayer構(gòu)建視頻播放器

    本文介紹了如何使用React構(gòu)建一個(gè)基礎(chǔ)的視頻播放器組件,并探討了常見(jiàn)問(wèn)題和易錯(cuò)點(diǎn),通過(guò)組件化思想和合理管理狀態(tài),可以實(shí)現(xiàn)功能豐富且性能優(yōu)化的視頻播放器
    2025-01-01
  • 如何在react項(xiàng)目中做公共配置文件

    如何在react項(xiàng)目中做公共配置文件

    這篇文章主要介紹了如何在react項(xiàng)目中做公共配置文件問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • React Native按鈕Touchable系列組件使用教程示例

    React Native按鈕Touchable系列組件使用教程示例

    這篇文章主要為大家介紹了React Native按鈕Touchable系列組件使用教程示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • JavaScript中的useRef 和 useState介紹

    JavaScript中的useRef 和 useState介紹

    這篇文章主要給大家分享的是 JavaScript中的useRef 和 useState介紹,下列文章,我們將學(xué)習(xí) useRef 和 useState hook是什么,它們的區(qū)別以及何時(shí)使用哪個(gè)。 這篇文章中的代碼示例將僅涉及功能組件,但是大多數(shù)差異和用途涵蓋了類和功能組件,需要的朋友可以參考一下
    2021-11-11
  • 在React中編寫(xiě)class樣式的方法總結(jié)

    在React中編寫(xiě)class樣式的方法總結(jié)

    在TypeScript (TSX) 中編寫(xiě) CSS 樣式類有幾種方法,包括使用純 CSS、CSS Modules、Styled Components 等,本文給大家介紹了幾種常見(jiàn)方法的示例,通過(guò)代碼示例講解的非常詳細(xì),需要的朋友可以參考下
    2024-07-07

最新評(píng)論

乡宁县| 武清区| 思茅市| 禹城市| 道真| 平果县| 津南区| 济阳县| 东阳市| 哈巴河县| 叶城县| 漳州市| 曲周县| 元阳县| 长泰县| 宜昌市| 久治县| 绩溪县| 扎囊县| 东乡族自治县| 鄱阳县| 万山特区| 茶陵县| 古浪县| 利辛县| 齐齐哈尔市| 沾益县| 武宁县| 宁乡县| 玉屏| 湟源县| 成都市| 株洲县| 英超| 溆浦县| 那坡县| 黑龙江省| 扶绥县| 台南县| 德庆县| 苏尼特右旗|