diff --git a/miniprogram/app.js b/miniprogram/app.js index 0657238b90ef5e8673a57424bac39ed5c25f1035..fcf58d1fd3563e637d6c4df5cabcdc32f16766c1 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -71,6 +71,26 @@ App({ this.globalData = { setting: setting }; console.log('onLaunch', options) }, + + // + // 引入`towxml3.0`解析方法 + towxml:require('/towxml/index'), + + //声明一个数据请求方法 + getText: (url, callback) => { + wx.request({ + url: url, + header: { + 'content-type': 'application/x-www-form-urlencoded' + }, + success: (res) => { + if (typeof callback === 'function') { + callback(res); + }; + } + }); + }, + onShow(options) { // Do something when show. console.info('show', options) diff --git a/miniprogram/pages/homeContent/homeContent.js b/miniprogram/pages/homeContent/homeContent.js index cfed657938a03134c437e2e72fd1fb3d45db5a80..df1f4e819b667e4382919833e3657599fe0632d1 100644 --- a/miniprogram/pages/homeContent/homeContent.js +++ b/miniprogram/pages/homeContent/homeContent.js @@ -18,20 +18,41 @@ Page({ */ data: { content:'子组件的content', - homeHeaderItem:'' + homeHeaderItem:'', + isLoading: true, + article: {} }, observers:{ }, - - /** + /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - console.log('进入homePage home-content 渲染开始 onload') - console.log('传递的header-item',options,this) + onLoad: function () { + const _ts = this; + + app.getText('https://www.vvadd.com/wxml_demo/demo.txt?v=2',res => { + let obj = app.towxml(res.data,'markdown',{ + // theme:'dark', + events:{ + tap:e => { + console.log('tap',e); + }, + change:e => { + console.log('todo',e); + } + } + }); + + _ts.setData({ + article:obj, + isLoading: false + }); + }) }, + + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/miniprogram/pages/homeContent/homeContent.json b/miniprogram/pages/homeContent/homeContent.json index 79be44697c984a70a0edc96443791473988a4bda..9ffe4e7dd8508fd72b9a9a4e6161e6f42033548f 100644 --- a/miniprogram/pages/homeContent/homeContent.json +++ b/miniprogram/pages/homeContent/homeContent.json @@ -1,5 +1,7 @@ { + "navigationBarBackgroundColor": "#ffffff", + "navigationBarTextStyle": "black", "usingComponents": { - + "towxml":"/towxml/towxml" } } \ No newline at end of file diff --git a/miniprogram/pages/homeContent/homeContent.wxml b/miniprogram/pages/homeContent/homeContent.wxml index 9b1cbf0acc129363d3b3f279cac7ba8e2c4090ed..6680f708211d0812a5c4cf898f1501322e226d56 100644 --- a/miniprogram/pages/homeContent/homeContent.wxml +++ b/miniprogram/pages/homeContent/homeContent.wxml @@ -1,8 +1,17 @@ - -content内容 -{{headerItem}} -{{content + headerItem}} + + + + + + + + + + + + + \ No newline at end of file