0

私は Vue を初めて使用し、コンポーネント内で jQuery (または単純な js) を操作する方法をよく理解していません。

component_1.vue内部にフォームがあるコンポーネントがあります:

<template>
    <div>
        <textarea v-model="article.content" id="contentInput"></textarea>
    </div>
</template>

ここで、このテキストエリアに js テキストエリア レイアウト ( Trumbowyg )を使用したいと考えています。どうすればこれを機能させることができますか?

ライフサイクル フックconsole.log(document.getElementById('contentInput'));内で実行しても、 が返されます。フック内の jQuery のチェックでが返されるので、jQuery が定義されます。コンソールにエラーが出力されません。created()nullcreated()JQUERY

これは私のjsの一部です:

export default {
    props: {
        id: Number
    },
    data() {
        return {
            article: [],
        }
    },
    components: {},
    created() {
        this.fetchArticle();
        if (typeof jQuery === 'undefined') {
            console.log('NOT');
        } else {
            console.log('JQUERY');
        }
        console.log(document.getElementById('contentInput'));
        $('#contentInput').trumbowyg({
            // TRUMBOWYG CONFIGURATION
        });
    },
    methods: {
        fetchArticle() {
            //FETCH ARTICLE FROM DB VIA AXIOS
        },
    }
}

html にアクセスして、trumbowyg のようなものを操作するにはどうすればよいですか?

4

0 に答える 0