Closed bigGoodMan closed 5 years ago
现在我只能怎么写了 全局变量 vant 研发环境直接引用cdn 但是我们的cdn只开放生产环境域名,本地读取不到。。。只能改成你们官方的cdn了
不是很理解你的问题,在 vant 的 index.js
文件里只会导出 Lazyload 模块,不会自动 use,你可以在项目里手动注册该组件
对啊
import {install,Lazyload} from 'vant'
Vue.use(install)
Vue.use(Lazyload)
然后我想不要把它打包就去(非开发环境会使用cdn)
externals: { vant: 'vant' }
会出现问题 就是
this.$toast{ ...optiosn, onClose () {} // 虽然关闭了,但是onClose方法不执行了 }
我以为方法错了,然后我用
this.$toast{ ...optiosn, mask: true, close() {} // 执行了但是蒙层没有关闭 }
使用的是vue-cli3脚手架
目前我的做法是所有环境都引入cdn 然后Vue.use('vant')这样是没有问题的
在开发环境不建议用 external 来做,可以用代理工具把文件代理到本地,比如 https://github.com/youzan/zan-proxy
在开发环境不建议用 external 来做,可以用代理工具把文件代理到本地,比如 https://github.com/youzan/zan-proxy
谢谢
Describe the bug 全局use引入插件的时候lazyload指令无效
Screenshots 我看源码 `var components = [Actionsheet, AddressEdit, AddressList, Area, Badge, BadgeGroup, Button, Card, Cell, CellGroup, Checkbox, CheckboxGroup, Circle, Col, Collapse, CollapseItem, ContactCard, ContactEdit, ContactList, Coupon, CouponCell, CouponList, DatetimePicker, Dialog, Field, GoodsAction, GoodsActionBigBtn, GoodsActionMiniBtn, Icon, ImagePreview, Info, List, Loading, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Panel, PasswordInput, Picker, Popup, Progress, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Sku, Slider, Step, Stepper, Steps, SubmitBar, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, TreeSelect, Uploader];
var install = function install(Vue) { components.forEach(function (Component) { Vue.use(Component); }); }; / istanbul ignore if /
if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); }
export { install, version, Actionsheet, AddressEdit, AddressList, Area, Badge, BadgeGroup, Button, Card, Cell, CellGroup, Checkbox, CheckboxGroup, Circle, Col, Collapse, CollapseItem, ContactCard, ContactEdit, ContactList, Coupon, CouponCell, CouponList, DatetimePicker, Dialog, Field, GoodsAction, GoodsActionBigBtn, GoodsActionMiniBtn, Icon, ImagePreview, Info, Lazyload, List, Loading, Locale, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Panel, PasswordInput, Picker, Popup, Progress, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Sku, Slider, Step, Stepper, Steps, SubmitBar, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, TreeSelect, Uploader, Waterfall }; export default { install: install, version: version };`
那就是必须拆开了
import {install,Lazyload} from 'vant'
那这样的话我用cdn 然后用webpack externals也会把它打包进去 EnvironmentReproduce