fix:解决初始化值initialValue无法动态改变的问题
This commit is contained in:
parent
b0d4986d42
commit
214bae06f6
@ -141,3 +141,7 @@ v0.8.0
|
||||
1.新增md文件导出和读取功能
|
||||
2.修改预览部分样式
|
||||
3.修改头部菜单样式
|
||||
|
||||
v0.9.3
|
||||
1.解决初始化值initialValue无法动态改变的问题
|
||||
2.修改了打包配置
|
||||
|
BIN
build/iconfont.eot
Normal file
BIN
build/iconfont.eot
Normal file
Binary file not shown.
116
build/iconfont.svg
Normal file
116
build/iconfont.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 49 KiB |
BIN
build/iconfont.ttf
Normal file
BIN
build/iconfont.ttf
Normal file
Binary file not shown.
1272
build/index.js
Normal file
1272
build/index.js
Normal file
File diff suppressed because one or more lines are too long
7
dist/build.js
vendored
Normal file
7
dist/build.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/build.js.map
vendored
Normal file
1
dist/build.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vue-meditor",
|
||||
"description": "一款使用marked和highlight.js开发的一款markdown编辑器",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"author": "zhaoxuhui<1258835133@qq.com>",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
@ -12,7 +12,8 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
|
||||
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
|
||||
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
|
||||
"build:npm": "cross-env NODE_ENV=npm webpack --progress --hide-modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"highlight.js": "^9.12.0",
|
||||
|
43
src/App.vue
43
src/App.vue
@ -1,35 +1,40 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div class="container">
|
||||
<mark-down @on-save="save" theme="OneDark" ></mark-down>
|
||||
<mark-down @on-save="save" theme="OneDark" :initialValue="initialValue"></mark-down>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkDown from './markdown/index' // 开发文件
|
||||
// import MarkDown from '../dist' // 引入打包好的文件
|
||||
// import MarkDown from './markdown/index' // 开发文件
|
||||
import MarkDown from "../build"; // 引入打包好的文件
|
||||
export default {
|
||||
name: 'app',
|
||||
components: {
|
||||
MarkDown
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
name: "app",
|
||||
components: {
|
||||
MarkDown
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
initialValue: ""
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
save(res) {
|
||||
console.log(res);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
this.initialValue = "# vue-markdown";
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
save(res){
|
||||
console.log(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
margin: 20px auto;
|
||||
border:1px solid #ccc;
|
||||
margin: 20px auto;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
</style>
|
||||
|
@ -465,6 +465,7 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
value() {
|
||||
clearTimeout(this.timeoutId);
|
||||
this.timeoutId = setTimeout(() => {
|
||||
@ -477,6 +478,9 @@ export default {
|
||||
const height_2 = this.$refs.textarea.scrollHeight;
|
||||
const height_3 = this.$refs.preview.scrollHeight;
|
||||
this.scrollHeight = Math.max(height_1, height_2, height_3);
|
||||
},
|
||||
initialValue() {
|
||||
this.value = this.initialValue;
|
||||
}
|
||||
},
|
||||
destroyed() { // 销毁时清除定时器
|
||||
|
@ -1,12 +1,13 @@
|
||||
var path = require('path')
|
||||
var webpack = require('webpack')
|
||||
const NODE_ENV = process.env.NODE_ENV;
|
||||
|
||||
module.exports = {
|
||||
entry: './src/index.js', // 打包为npm包时将此处修改为 ./src/index.js
|
||||
entry: NODE_ENV==='npm'?'./src/index.js':'./src/main.js',
|
||||
output: {
|
||||
path: path.resolve(__dirname, './dist'),
|
||||
publicPath: '/dist/',
|
||||
filename: 'index.js',// 打包为npm包时将此处修改为 index.js
|
||||
path: path.resolve(__dirname, NODE_ENV==='npm'?'./build':'./dist'),
|
||||
publicPath:NODE_ENV==='npm'? '/build/':'/dist/',
|
||||
filename: NODE_ENV==='npm'?'index.js':'build.js',
|
||||
libraryTarget: 'umd',
|
||||
library: 'markdown-vue',
|
||||
umdNamedDefine: true
|
||||
|
Loading…
Reference in New Issue
Block a user