微信公众号 自定义菜单栏目

版权声明:转载请评论留言 https://blog.csdn.net/solocao/article/details/88797186

我的核心写法,使用node
官方文档地址 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013

import * as client from 'superagent';

const createMenu = async function () {
  // @ts-ignore
  let access_token = await this.getGlobalToken();
  const url = `https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${access_token}`;
  const menu = [
    {
      "type": "view",
      "name": "菜单名称",
      "url": "http://xx.xxxx.wang"
    }];
  const data = await client.post(url).send({ button: menu }).catch(err => { console.log(err) });
  // @ts-ignore
  const result = JSON.parse(data.text);
  return { code: 1, msg: '设置成功', data: result }
}

猜你喜欢

转载自blog.csdn.net/solocao/article/details/88797186