Comments (5)
请提供 demo,我无法复现这个问题。
我用定时器模拟测试没有问题,或者你可以尝试在组件上添加 :KeepCursorInEnd="true"
属性
setInterval(() => {
code.value += "test \n";
}, 1000);
onChange(val, instance) {
const scrollInfo = instance.getScrollInfo();
instance.scrollTo(scrollInfo.left, scrollInfo.height);
}
from codemirror-editor-vue3.
请提供 demo,我无法复现这个问题。
我用定时器模拟测试没有问题,或者你可以尝试在组件上添加
:KeepCursorInEnd="true"
属性setInterval(() => { code.value += "test \n"; }, 1000); onChange(val, instance) { const scrollInfo = instance.getScrollInfo(); instance.scrollTo(scrollInfo.left, scrollInfo.height); }
我的demo如下,
我使用的是vue3+vite2,如果你的文档所示,
好像依旧无法滚动滚动条.
<template>
<Codemirror
v-model:value="code"
:options="cmOptions"
border
placeholder="test placeholder"
:height="500"
KeepCursorInEnd
@change="change"
/>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import Codemirror from "codemirror-editor-vue3";
// plugin-style
import "codemirror-editor-vue3/dist/style.css";
// language
import "codemirror/mode/javascript/javascript.js";
// theme
import "codemirror/theme/dracula.css"
const code = ref('')
const cmOptions = {
mode: 'text/javascript', // Language mode
theme: 'dracula', // Theme
lineNumbers: true, // Show line number
smartIndent: true, // Smart indent
indentUnit: 2, // The smart indent unit is 2 spaces in length
foldGutter: true, // Code folding
styleActiveLine: true, // Display the style of the selected row
}
const change = (msg, cm) => {
console.log(cm);
const scrollInfo = cm.getScrollInfo();
cm.scrollTo(scrollInfo.left, scrollInfo.height);
}
setInterval(() => {
code.value += "test \n";
}, 300);
onMounted(() => {
})
</script>
<style lang="less" scoped>
</style>
from codemirror-editor-vue3.
我试了你的代码,确实有这样的问题,但是我没有找到是什么原因导致的,但我修复了KeepCursorInEnd属性不生效的问题,今天测试后会发布一个版本
from codemirror-editor-vue3.
我试了你的代码,确实有这样的问题,但是我没有找到是什么原因导致的,但我修复了KeepCursorInEnd属性不生效的问题,今天测试后会发布一个版本
好的,谢谢.我自己找了两种方法可行,一种是直接用codemirror实例在计时器里面去scrllTo,另一种就是在change里面去拿到滚动高度,再用watch去scrollTo.都可以,就是直接在change回调里用实例滚动不行.如果可以,真心希望找出原因.
from codemirror-editor-vue3.
我仍然没有找到问题所在,但我在内部曲线解决了这个问题,现在你可以手动控制 scroll,或者使用KeepCursorInEnd属性,请更新到最新版本
from codemirror-editor-vue3.
Related Issues (20)
- type define error ts定义错误 HOT 2
- Why deafult height 200? HOT 2
- replaceSelection() 插入数据有具体的使用方式吗 HOT 4
- 请问大佬vue的模板如何支持语法高亮,现在的语言包语法高亮总是不对 HOT 3
- 编辑器提示功能配置设置问题 HOT 1
- 请问是否支持高亮某个关键字或支持v-html HOT 1
- when delete all code, change emits not correct, HOT 5
- Can't resolve 'codemirror/mode/javascript/javascript.js' HOT 1
- 火狐浏览器兼容问题 HOT 1
- 关于placeholder失效问题 HOT 1
- 请问能支持java代码编写吗 HOT 2
- 根据示例编引入组件提示Missing "./mode/javascript/javascript.js" export in "codemirror" package HOT 5
- 编辑器代码内容无法高亮,已引入相关js HOT 5
- 运行官网ts setup示例报错 HOT 2
- Failure when trying to pass tests with vitest in vue 3 project HOT 1
- Focus the editor HOT 2
- 使用WebStorm/IDEA生成的Vite+TS工程不支持语法高亮 HOT 4
- change event is not triggered HOT 2
- 2.3.1 is broken HOT 4
- 发现好多codemirror的属性都没有 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codemirror-editor-vue3.