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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| <template>
| <view class="container">
| <uni-card :cover="cover" @click="onClick">
| <div class="uni-body">
| <!-- 动态渲染 introduction 参数 -->
| <mp-html :content="introduction" />
| </div>
| </uni-card>
|
| </view>
| </template>
|
| <script>
| import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'; // 使用正确的路径
|
| export default {
| components: {
| mpHtml
| },
| data() {
| return {
| introduction: '', // 默认值
| extraIcon: {
| color: '#4cd964',
| size: '22',
| type: 'gear-filled'
| }
| };
| },
| onLoad() {
| // 从本地存储获取 introduction''
| const introduction = uni.getStorageSync('introduction');
| this.introduction = introduction || ''
| },
| methods: {
| shareToggle() {
| this.$refs.share.open();
| },
| onClick() {
| console.log('Card clicked');
| }
| }
| };
| </script>
|
| <style lang="scss" scoped>
| .container {
| padding: 20rpx;
| }
|
| .uni-body {
| width: 100%;
| min-height: 500rpx;
| }
|
| /* 分享按钮样式 */
| .share {
| width: 80rpx;
| height: 80rpx;
| background: #373E58;
| padding: 6rpx;
| border-radius: 8rpx;
| opacity: 0.4;
| display: flex;
| flex-direction: column;
| justify-content: center;
| align-items: center;
| color: #fff;
| font-size: 24rpx;
| position: fixed;
| right: 20rpx;
| top: 50%;
| transform: translateY(-50%);
| z-index: 999;
| }
|
| .share div {
| line-height: 16rpx;
| }
|
| /* 确保 mp-html 渲染的图片适应容器 */
| ::v-deep .mp-html img {
| max-width: 100%;
| height: auto;
| }
|
| /* 优化 mp-html 渲染的文本样式 */
| ::v-deep .mp-html {
| font-size: 28rpx;
| line-height: 40rpx;
| color: #333;
| }
|
| /* 标题样式 */
| ::v-deep .mp-html h1,
| ::v-deep .mp-html h2,
| ::v-deep .mp-html h3,
| ::v-deep .mp-html h4,
| ::v-deep .mp-html h5,
| ::v-deep .mp-html h6 {
| font-weight: bold;
| margin: 20rpx 0;
| }
|
| /* 列表样式 */
| ::v-deep .mp-html ul,
| ::v-deep .mp-html ol {
| padding-left: 40rpx;
| }
|
| /* 列表项样式 */
| ::v-deep .mp-html li {
| margin-bottom: 10rpx;
| }
| </style>
|
|