百变天气——为你的小程序加个天气模块吧
发布于 4 年前 作者 zengli 1709 次浏览 来自 分享

百变天气小程序插件上线了,帮助小程序快速接入天气预报模块。

授权插件

添加插件,搜索插件id:wxc5af96529fe97d4b或“百变天气”添加


引入插件

修改app.json

{
  "permission": {
    "scope.userLocation": {
      "desc": "根据用户当前位置获取实时天气信息"
    }
  },
  "usingComponents": {
    "weather": "plugin://weather/weather"
  },
  "plugins": {
      "weather": {
        "version": "1.0.1",
        "provider": "wxc5af96529fe97d4b"
      }
    }
  }
}

如果只有一个页面需要用到,那么在页面的page.json中引入

{
  "usingComponents": {
    "weather": "plugin://weather/weather"
  }
}

使用代码

Demo

# 只渲染一个小方块
<weather size="xs" theme="dark" bgcolor="#0081ff" />
# 占整行渲染
<weather size="sm" theme="light" bgcolor="#0081ff"/>

样式

# 只渲染一个小方块 需要在wxss中加入样式 
weather {
  display: inline-block;
}

占用空间大小 size

  1. xs
  2. sm

支持2种风格 theme

  1. light 白色
  2. dark 黑色

背景色 bgcolor

直接填写颜色值就可以,支持以下两种

  1. #0081ff
  2. rgb(0, 129, 255);

展示效果



3 回复

您好,我的小程序引入天气插件后刚才显示天气插件异常,之前用着还没事,这个不是24小时都能用的吗?

还有个问题就是怎么让天气信息显示在状态栏那里?

你好,我刚才在微信公众平台申请使用您的天气插件,麻烦你同意一下可以吗

回到顶部