Skip to content

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'extension') #231

Description

@AsherAla

Describe the bug

感谢作者的共享,vue-codemirror 确实是一个很好的项目。
但是我在vue3项目中使用时遇到了一些问题,下面是我写的代码:
引入依赖:

Image

运行不会报错,只要打开使用了codemirror的页面时会报错:

Image

`import { Codemirror } from 'vue-codemirror'
import { oneDark } from '@codemirror/theme-one-dark'
import { json } from '@codemirror/lang-json'

`

Reproduction

`

<script setup lang="ts"> import type { CSSProperties } from 'vue' import { ref, watchEffect } from 'vue' import { Codemirror } from 'vue-codemirror' import { oneDark } from '@codemirror/theme-one-dark' import { json } from '@codemirror/lang-json' interface Props { codeStyle?: CSSProperties // 代码样式 dark?: boolean // 是否暗黑主题 code?: string // 代码字符串 } const props = withDefaults(defineProps(), { codeStyle: () => ({}), dark: false, code: '' }) const extensions = props.dark ? [json(), oneDark] : [json()] const codeValue = ref('') watchEffect(() => { codeValue.value = props.code }) const emits = defineEmits(['update:code', 'ready', 'change', 'focus', 'blur']) function handleReady(payload: any) { // console.log('ready') emits('ready', payload) } function onChange(value: string, viewUpdate: any) { emits('change', value, viewUpdate) emits('update:code', value) } function onBlur(viewUpdate: any) { emits('blur', viewUpdate) } </script>

`

System Info

Browsers

Used Package Manager

pnpm

Validations

  • Read the the documentation in detail.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions