花里胡哨的天气插件代码生成

一、生成天气代码样式
我这里使用的是和风天气的官方链接生成的
https://widget.qweather.com/
在这里插入图片描述
这里有个坑,就是你创建的内容使用不了,应该是要收费才能是使用。唯一能使用的就是我下面这个url。
二、天气组件

<template>
  <div class="weather">
    <div id="he-plugin-standard"></div>
  </div>
</template>
<script lang="ts" setup>
import { onMounted } from "vue";
window.WIDGET = {
  CONFIG: {
    layout: "1",
    width: "550",
    height: "200",
    background: "1",
    dataColor: "FFFFFF",
    borderRadius: "5",
    key: "fcd4fc1e48a144a483b7af74284229b8", //这里使用自己生成的key
  },
};

onMounted(() => {
  weather();
});
const weather = () => {
  const s = document.createElement("script");
  s.type = "text/javascript";
  s.src = "https://widget.qweather.net/standard/static/js/he-standard-common.js?v=2.0";
  document.body.appendChild(s);
};
</script>
<style lang="scss" scoped>
.weather {
  width: 60px !important;
  height: 100%;
}
</style>

三、引用

<template>
  <Weather class="weather"></Weather>
</template>

<script lang="ts" setup>
import Weather from "/@/components/Weather.vue";
</script>
<style lang="scss" scoped>
.weather {
  width: 80px;
  height: 40px;
}
</style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值