Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

[需求]支持开发小程序组件 #368

Closed
yesmeck opened this issue Nov 18, 2019 · 6 comments
Closed

[需求]支持开发小程序组件 #368

yesmeck opened this issue Nov 18, 2019 · 6 comments
Assignees
Labels

Comments

@yesmeck
Copy link
Member

yesmeck commented Nov 18, 2019

新增一个 component 子命令,可以把项目构建成小程序组件:

$ remax component build

组件开发的目录结构:

.
├── packages.json
├── remax.config.js
└── src
    ├── component.config.js
    └── index.js
@yesmeck yesmeck changed the title [需求]支持开发小程序插件 [需求]支持开发小程序组件 Dec 16, 2019
@fwh1990
Copy link

fwh1990 commented Apr 8, 2020

请问如果想要创建remax的第三方UI库,就需要用到这个吧?

@Darmody
Copy link
Contributor

Darmody commented Apr 8, 2020

请问如果想要创建remax的第三方UI库,就需要用到这个吧?

不用的。这个是给原生自定义组件用的。

第三方 UI 库可以参考 https://github.com/AnnaSearl/anna-remax-ui

@fwh1990
Copy link

fwh1990 commented Apr 8, 2020

目前的需求是用户能在react文件直接import我的包,但包里使用的是原生小程序的代码 @Darmody

@fwh1990
Copy link

fwh1990 commented Apr 8, 2020

目前的需求是用户能在react文件直接import我的包,但包里使用的是原生小程序的代码 @Darmody

@Darmody 这种案例有吗?

@Darmody
Copy link
Contributor

Darmody commented Apr 8, 2020

目前的需求是用户能在react文件直接import我的包,但包里使用的是原生小程序的代码 @Darmody

@Darmody 这种案例有吗?

https://remaxjs.org/guide/custom-component

Remax 本身就支持直接引入原生自定义组件

@yesmeck
Copy link
Member Author

yesmeck commented Apr 27, 2020

发现之前想错了,编译到组件的话就不需要 bundle。

假设这样一个组件:

import * React from 'react';

export default () => {
  return <View>hello</View>;
}

编译后:

import * React from 'react';
import { createComponentConfig } from 'remax';

const _component = () => {
  return <View>hello</View>;
}

export default Component(createComponentConfig(_component));

以及 index.axmlindex.json

由项目自己去依赖 react 和 remax。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants