forked from NervJS/taro-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnews.js
40 lines (35 loc) · 1.08 KB
/
news.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { useEffect } from 'react'
/**
* Taro介绍 - 新闻资讯
*
* 羚珑内容分发 SDK 接入文档详见:
* http://tls-pre.jd.com/distribute-sdk-docs/docs/
*/
function Index () {
const newsStyle = {
width: '100%',
height: 'auto',
cursor: 'pointer',
}
useEffect(() => {
if (!window.LRT) return
// 注册资源位
window.LRT.register({
zoneId: '1485579794201481218', // 羚珑专区id
debug: false, // 是否开启debug模式
positionId: '1485796590212263937', // 必传参数,资源位id
type: 'img', // 资源位类型
containerId: 'news', // 注册资源位成功后,资源位预览图的 DOM 节点
backupUrl: 'https://img20.360buyimg.com/img/jfs/t1/220737/13/10934/81315/61dd7009Ead9f1ca0/81f28ce8f80dce8e.jpg', // 兜底图
backupLink: 'https://mp.weixin.qq.com/s/Hud405mLileIEzHX3Z-ueQ', // 兜底链接
onClick (e, { url }) {
// 点击时的回调
window.open(url)
},
})
}, [])
return (
<div id="news" style={newsStyle}></div>
)
}
export default Index