title: swan.setMetaKeywords header: develop nav: api

sidebar: swan-setMetaKeywords

不推荐使用。

解释: 设置 web 版小程序 keywords meta 信息。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。

方法参数

Object object

object参数说明

属性名 类型 必填 默认值 说明
content String 需要设置的 keywords 内容
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

示例

在开发者工具中预览效果

扫码体验

在开发者工具中,单击“预览”,输入您的APPID,单击“WEB预览”,百度APP中扫码体验。

图片示例

sidebar: swan-setMetaKeywords - 图1

代码示例

  • 在 swan 文件中
  1. <view class="wrap">
  2. <button type="primary" bindtap="setMetaKeywords">setMetaKeywords</button>
  3. </view>
  • 在 js 文件中
  1. Page({
  2. onShow() {
  3. swan.setMetaKeywords({
  4. content: '小程序, 关键字',
  5. success: res => {
  6. console.log('setMetaKeywords success', res);
  7. },
  8. fail: err => {
  9. console.log('setMetaKeywords fail', err);
  10. }
  11. });
  12. }
  13. });
  • 在 css 文件中
  1. .wrap {
  2. padding: 50rpx 30rpx;
  3. }