vue事件给Flutter传值
//vue事件 通过clickGoods.postMessage方法
methods: {
// 发送给flutter的事件
sendData(shopinfo) {
// eslint-disable-next-line no-undef
clickGoods.postMessage(JSON.stringify(shopinfo));
},
}
Flutter接收
//接收vue的传参
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
return JavascriptChannel(
name: 'clickGoods',
onMessageReceived: (JavascriptMessage message) {
McLog.d("setData ---------- message ${message.message}");
try {
final jsonMap = json.decode(message.message ?? {});
GoodsDetailPage.jump(context, SPGoodsItem.fromJson(GoodsConverter.convertGoodsItemJson(jsonMap)), 0);
} catch (e) {}
});
}