Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何引入原生自定义组件? #61

Open
dannnney opened this issue Nov 16, 2018 · 1 comment
Open

请问如何引入原生自定义组件? #61

dannnney opened this issue Nov 16, 2018 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@dannnney
Copy link

请问如何引入原生自定义组件? 谢谢

@BuptStEve
Copy link
Member

这个问题本质上是把已有的原生自定义组件【复制】到 dist/ 目录中,假设这些组件放在 src/foobar/ 目录下,需要拷贝到 dist/foobar/ 下。可以在 tua-mp.config.js 这样写:

// tua-mp.config.js
module.exports = {
    chainWebpack: (config) => {
        config
            .plugin('copy-webpack-plugin')
            .tap(([ patterns, ...rest ]) => ([
                [
                    ...patterns,
                    
                    // 小程序组件目录
                    { from: 'foobar/', to: 'foobar/' },
                ],
                ...rest,
            ]))
    },
}

假设其中有某个组件叫做 Dialog,之后在页面、组件里引入路径就是这样

{
    "usingComponents": {
        "Dialog": "/foobar/Dialog/Dialog"
    },
}

回头补一下文档和示例...

@BuptStEve BuptStEve added the good first issue Good for newcomers label Dec 3, 2018
@BuptStEve BuptStEve self-assigned this Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants