Skip to content

Commit 14605d5

Browse files
committed
fix Solve the problem of markdown not rendering
1 parent c52ea54 commit 14605d5

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

admin/src/views/article/add.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@
3838
</template>
3939

4040
<script>
41+
// import with ES6
42+
// import mavonEditor from 'mavon-editor'
43+
import { mavonEditor } from 'mavon-editor'
44+
// markdown-it对象:md.s_markdown, md => mavonEditor 实例
45+
import 'mavon-editor/dist/css/index.css'
46+
import { getToken } from '@/utils/auth'
47+
4148
import { postAdd, axios } from '@/api/article'
4249
import { getList } from '@/api/category'
4350
4451
export default {
52+
components: {
53+
mavonEditor
54+
},
4555
data() {
4656
return {
4757
item: '',
@@ -55,7 +65,9 @@ export default {
5565
markdown: '',
5666
content: '0',
5767
is_top: 0,
58-
loading: false
68+
loading: false,
69+
// 请求需要携带 token
70+
uploadUrl: process.env.VUE_APP_BASE_API + '/api/upload?token=' + getToken()
5971
},
6072
rules: {
6173
title: [
@@ -138,7 +150,7 @@ export default {
138150
var formdata = new FormData()
139151
formdata.append('image', $file)
140152
axios({
141-
url: 'http://localhost/',
153+
url: this.uploadUrl,
142154
method: 'post',
143155
data: formdata,
144156
headers: { 'Content-Type': 'multipart/form-data' }

admin/src/views/article/edit.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@
3838
</template>
3939

4040
<script>
41+
// import with ES6
42+
// import mavonEditor from 'mavon-editor'
43+
import { mavonEditor } from 'mavon-editor'
44+
// markdown-it对象:md.s_markdown, md => mavonEditor 实例
45+
import 'mavon-editor/dist/css/index.css'
46+
import { getToken } from '@/utils/auth'
47+
4148
import { axios, edit, postEdit } from '@/api/article'
4249
import { getList } from '@/api/category'
4350
4451
export default {
52+
components: {
53+
mavonEditor
54+
},
4555
data() {
4656
return {
4757
item: '',
@@ -55,7 +65,9 @@ export default {
5565
markdown: '',
5666
content: '0',
5767
is_top: 0,
58-
loading: false
68+
loading: false,
69+
// 请求需要携带 token
70+
uploadUrl: process.env.VUE_APP_BASE_API + '/api/upload?token=' + getToken()
5971
},
6072
rules: {
6173
title: [
@@ -156,7 +168,7 @@ export default {
156168
var formdata = new FormData()
157169
formdata.append('image', $file)
158170
axios({
159-
url: 'http://localhost/',
171+
url: this.uploadUrl,
160172
method: 'post',
161173
data: formdata,
162174
headers: { 'Content-Type': 'multipart/form-data' }

0 commit comments

Comments
 (0)