Cordova打包的Vue项目在IOS无法拉起支付宝和微信支付

背景

在用Cordova打包Vue项目并添加IOS平台时,在服务器后台没有报异常,且支付宝以及微信的调用的链接在

浏览器中能正常调用时,此时查看Cordova项目下的config.xml文件。

解决

打开config.xml文件

加入:

 <allow-intent href="weixin:*" />
 <allow-intent href="alipays:*" />

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
你可以尝试使用以下步骤来实现在 Cordova 环境下打包 Vue 项目并调用拍照功能: 1. 在 Cordova 项目根目录下执行以下命令安装 Cordova 插件 Camera: ``` cordova plugin add cordova-plugin-camera ``` 2. 在 Vue 项目中安装 Cordova 插件 Camera 的 TypeScript 类型: ``` npm install --save-dev @types/cordova-plugin-camera ``` 3. 在 Vue 项目的入口文件 main.ts 中添加以下代码: ``` declare var navigator: any; const app = createApp(App); app.config.globalProperties.$takePicture = () => { return new Promise((resolve, reject) => { navigator.camera.getPicture((imageData: string) => { resolve(`data:image/jpeg;base64,${imageData}`); }, (error: any) => { reject(error); }, { quality: 50, destinationType: navigator.camera.DestinationType.DATA_URL }); }); }; app.mount('#app'); ``` 上述代码会将 Cordova 的 Camera 插件添加到 Vue 的全局属性中,以便在 Vue 组件中调用。 4. 在 Vue 组件中调用 `$takePicture` 方法: ``` <template> <div> <button @click="takePicture">Take Picture</button> <img :src="image" v-if="image" /> </div> </template> <script lang="ts"> import { defineComponent, ref } from 'vue'; export default defineComponent({ setup() { const image = ref(''); const takePicture = async () => { try { const imageData = await (window as any).$takePicture(); image.value = imageData; } catch (error) { console.error(error); } }; return { image, takePicture, }; }, }); </script> ``` 上述代码会在 Vue 组件中定义 `$takePicture` 方法的调用,在用户点击“Take Picture”按钮时调用该方法。调用成功后,图片的 base64 编码会被设置到 Vue 组件的 `image` 变量中,并渲染到页面上。 以上是一个简单的实现,在实际开发中你可能需要进行更多的配置和调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

霸道流氓气质

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值