在pages.json或app.json对面页面路由引入一下自定义组件[图片]
分包引入插件页面空白,但是回调是走success的<template> <view style="height: 100vh"> <chat bind:queryCallback="getQueryCallback" bind:openWebview="openWebview" bind:openMiniProgram="openMiniProgram" /> </view> </template> <script setup> import { reactive, getCurrentInstance, ref } from 'vue' import { onReady, onLoad, onUnload, onHide } from "@dcloudio/uni-app" let userInfo = ref({}) let plugin = requirePlugin("chatbot"); onLoad((option) => { userInfo.value = uni.getStorageSync('userInfo'); let userName = '' if (userInfo.value?.image) { userName = userInfo.value?.name } let userImage = '' if (userInfo.value?.image_logo) { userImage = userInfo.value?.image_logo } console.log('userInfo.value.openid') console.log(userInfo.value.openid) plugin.init({ appid: "我的ID", //微信对话开放平台小程序插件appid openid: userInfo.value.openid, // 小程序用户的openid,必填项 userHeader: userImage, // 用户头像,不传会弹出登录框 userName: userName, // 用户昵称,不传会弹出登录框 anonymous: false, // 是否允许匿名用户登录,版本1.2.9后生效, 默认为false,设为true时,未传递userName、userHeader两个字段时将弹出登录框 success: (res) => { console.log('res') console.log(res) }, //非必填 fail: (error) => { console.log('error') console.log(error) }, //非必填 }); }) </script> <style> [图片] </style>
07-22