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

vant2.12.6 使用unplugin-vue-components 实践 #20

Open
colorfulWorld opened this issue Aug 1, 2022 · 0 comments
Open

vant2.12.6 使用unplugin-vue-components 实践 #20

colorfulWorld opened this issue Aug 1, 2022 · 0 comments

Comments

@colorfulWorld
Copy link
Owner

colorfulWorld commented Aug 1, 2022

1、vue3 dialog 组件调用无效,并默认弹出,关闭后无法打开
2、Toast/Dialog/ImagePreview 等组件导出的是函数,而不是 Vue 组件,因此 unplugin-vue-components 无法自动导入这几个组件的样式,目前需要手动处理。(奇怪,我这里是正常的)

// Toast
import { Toast } from 'vant';
import 'vant/es/toast/style';

// Dialog
import { Dialog } from 'vant';
import 'vant/es/dialog/style';

// Notify
import { Notify } from 'vant';
import 'vant/es/notify/style';

// ImagePreview
import { ImagePreview } from 'vant';
import 'vant/es/image-preview/style';
  1. webpack 配置: 不要再全局引入vant,不然会全部打包。兼容原本的按需引入。
const Components = require('unplugin-vue-components/webpack');
const { VantResolver } = require('unplugin-vue-components/resolvers');
module.exports = {
  resolve: {
          alias: {
              '@': path.resolve(__dirname, 'src')
          },
          extensions: ['.js', '.vue', '.json', '.mjs']
      },
  plugins: [
          Components({
              resolvers: [
                VantResolver()
            ]
        })
]
}

变动大,由于2 这个问题会导致项目变动多,很多地方直接使用的van-dialog, 要全量替换,而且后续维护也麻烦。。关键在于外包团队的难以控制问题

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

No branches or pull requests

1 participant