mirror of
https://github.com/501351981/vue-office.git
synced 2025-07-25 07:41:42 +08:00
fix: excel autoFouce=false
This commit is contained in:
parent
6f823c64ad
commit
6c288ea6e8
File diff suppressed because one or more lines are too long
2
examples/dist/index.html
vendored
2
examples/dist/index.html
vendored
@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vue-office/examples/dist/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue</title>
|
||||
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-8dfd4953.js"></script>
|
||||
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-772f353d.js"></script>
|
||||
<link rel="stylesheet" href="/vue-office/examples/dist/assets/index-3a74d980.css">
|
||||
</head>
|
||||
<body>
|
||||
|
@ -1,11 +1,12 @@
|
||||
export function readOnlyInput(mutationsList, observer){
|
||||
console.log(mutationsList, observer);
|
||||
for(let mutation of mutationsList) {
|
||||
if(mutation.target.className === 'hide-input'){
|
||||
let input = mutation.target.childNodes[0];
|
||||
if(input){
|
||||
input.readOnly = true;
|
||||
}
|
||||
export function readOnlyInput(ref){
|
||||
let root = ref.value;
|
||||
if(root){
|
||||
|
||||
let nodes = root.querySelectorAll('.hide-input');
|
||||
console.log(nodes);
|
||||
for(let node of nodes){
|
||||
let input = node.childNodes[0];
|
||||
input && (input.readOnly = true);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import Spreadsheet from 'x-data-spreadsheet';
|
||||
import {getData, readExcelData, transferExcelToSpreadSheet} from './excel';
|
||||
import {renderImage, clearCache} from './media';
|
||||
import {readOnlyInput} from './hack';
|
||||
import {debounce} from 'lodash';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'VueOfficeExcel',
|
||||
@ -60,10 +61,12 @@ export default defineComponent({
|
||||
emit('error', e);
|
||||
});
|
||||
}
|
||||
const observer = new MutationObserver(readOnlyInput);
|
||||
const observerCallback = debounce(readOnlyInput, 20).bind(this,rootRef);
|
||||
const observer = new MutationObserver(observerCallback);
|
||||
const observerConfig = { attributes: true, childList: true, subtree: true };
|
||||
onMounted(() => {
|
||||
observer.observe(rootRef.value, observerConfig);
|
||||
observerCallback(rootRef);
|
||||
window.xs = xs = new Spreadsheet(rootRef.value, {
|
||||
mode: 'read',
|
||||
showToolbar: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user