微信小程序插件使用更新问题

以微信同声传译为例
一、使用
1,在微信公众平台:添加插件(设置-第三方设置-插件管理)
2.项目中
app.json中:

  "sitemapLocation": "sitemap.json",
    "plugins": {
      "WechatSI": {
        "version": "0.2.3",
        "provider": "wx069ba97219f66d99"
      }
    }

新页面js文件中
添加

  var plugin = requirePlugin('WechatSI')
    let manager = plugin.getRecordRecognitionManager()

事件

luyinstart() {
    manager.onStart = function (res) {
      console.log("成功开始录音识别", res)
    }
    manager.start({ duration: 30000, lang: "zh_CN" })
  },
  luyinend(e) {
    type = e.currentTarget.dataset.type
    console.log(type)
    manager.stop()
    var _this = this
    manager.onStop = function (res) {
      console.log("record file path", res.tempFilePath)
      console.log("result", res.result)
      for (var i = 0; i < _this.data.list.length; i++) {

        if (type == _this.data.list[i].name) {

          console.log(i)
          console.log(res.result)
          var up = "list[" + i + "].value"
          _this.setData({
            [up]: res.result
          })
        }
      }
    }
  },

新页面wxml文件中

 <view>
    <view class='need'>需求描述</view>
    <textarea class='describe' value='{{textvalue}}' bindinput='textareainput' data-value='{{textvalue}}'></textarea>
    <button class='voice' bindtouchstart='luyinstart' bindtouchend='luyinend'>长按描述</button>
  </view>

二、更新
在app.json里面 把version版本号改为当前最新版本号

发布了17 篇原创文章 · 获赞 1 · 访问量 2737

猜你喜欢

转载自blog.csdn.net/qq_42014265/article/details/96479870