Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
5f3e3f69
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
719
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f3e3f69
编写于
12月 07, 2020
作者:
d-u-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: <ad> 优化示例,拆分为2个示例
上级
3493124e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
36 deletion
+51
-36
docs/component/ad.md
docs/component/ad.md
+51
-36
未找到文件。
docs/component/ad.md
浏览文件 @
5f3e3f69
...
...
@@ -90,24 +90,11 @@ App和微信小程序的ad组件没有type属性,可以用于banner,也可
<template>
<view
class=
"content"
>
<!-- App平台
示例 1
-->
<!-- App平台 -->
<!-- adpid="1111111111" 此广告位标识仅在HBuilderX标准基座中有效,仅用于测试,替换为自己申请获取的广告位标识 -->
<view
class=
"ad-view"
>
<ad
adpid=
"1111111111"
@
load=
"onload"
@
close=
"onclose"
@
error=
"onerror"
></ad>
</view>
<!-- App平台 示例 2 -->
<!-- 需要时可自定义属性,监听到 error 回调后(e.target可以取到),开发者可以针对性的处理,比如隐藏广告组件的父容器,以保证用户体验 -->
<view
class=
"ad-view"
v-for=
"adItem in adList"
:key=
"adItem.id"
>
<ad
:adpid=
"adItem.adpid"
:data-xx=
"adItem.id"
></ad>
</view>
<!-- App平台 示例 3 (手动请求广告数据 仅App平台支持) -->
<view>
<button
@
click=
"getAdData"
>
Get ad data
</button>
</view>
<view
class=
"ad-view"
>
<ad
:data=
"adData
"
></ad>
<ad
adpid=
"1111111111"
:data-xx=
"adItem.id"
@
load=
"onload"
@
close=
"onclose"
@
error=
"onerror
"
></ad>
</view>
<!-- 微信小程序 -->
...
...
@@ -127,25 +114,63 @@ App和微信小程序的ad组件没有type属性,可以用于banner,也可
</view>
</template>
<script>
export
default
{
data
()
{
return
{
title
:
'
ad
'
}
},
methods
:
{
onload
(
e
)
{
console
.
log
(
"
onload
"
);
},
onclose
(
e
)
{
console
.
log
(
"
onclose:
"
+
e
.
detail
);
},
onerror
(
e
)
{
console
.
log
(
"
onerror:
"
+
e
.
detail
.
errCode
+
"
message::
"
+
e
.
detail
.
errMsg
);
}
}
}
</script>
<style>
.content
{
background-color
:
#DBDBDB
;
padding
:
10px
;
}
.ad-view
{
background-color
:
#FFFFFF
;
margin-bottom
:
10px
;
}
</style>
```
```
javascript
api的方式(仅app平台支持)
```
html
<template>
<view
class=
"content"
>
<view
class=
"ad-view"
>
<ad
:data=
"adData"
></ad>
</view>
</view>
</template>
<script>
export
default
{
data
()
{
return
{
title
:
'
uni-app ad
'
,
adList
:
[],
title
:
'
ad
'
,
adData
:
{}
}
},
onReady
:
function
(
e
)
{
// 显示 4 个广告
for
(
let
i
=
0
;
i
<
4
;
i
++
)
{
this
.
adList
.
push
({
id
:
i
,
adpid
:
"
1111111111
"
})
}
this
.
getAdData
()
},
methods
:
{
getAdData
:
function
(
e
)
{
...
...
@@ -163,21 +188,11 @@ export default {
console
.
log
(
err
);
}
)
},
onload
(
e
)
{
console
.
log
(
"
onload
"
);
},
onclose
(
e
)
{
console
.
log
(
"
onclose:
"
+
e
.
detail
);
},
onerror
(
e
)
{
console
.
log
(
"
onerror:
"
+
e
.
detail
.
errCode
+
"
message::
"
+
e
.
detail
.
errMsg
);
}
}
}
```
</script>
```
css
<style>
.content
{
background-color
:
#DBDBDB
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录