fastadmin导入vue

前台 require-frontend.js或frontend-init.js

后台 require-backend.js或backend-init.js

后台

方法一

require-backend.js

在 paths 中加入’vue’:‘…/libs/vue/vue.min’,
在shim 中加入


paths: {
	......
	......
	
	'vue':'../libs/vue/vue.min',
}
shim: {
		......
		......
		
        'vue': {
            exports: 'Vue'
        },
}

方法二:
在backend-init.js中加入


require.config({
    paths: {
        'vue': "../libs/vue/dist/vue.global"
    },
    // shim依赖配置
    shim: {
        'vue': {
            exports: 'Vue'
        }
    }
});

    define(['backend'], function (Backend) {
    
});

最后在 js 中加入

前面是小写 vue , 后面是大写 Vue

define(['jquery', 'bootstrap', 'backend', 'table', 'form','vue'], function ($, undefined, Backend, Table, Form,Vue) {

define(['jquery', 'bootstrap', 'backend', 'table', 'form','vue'], function ($, undefined, Backend, Table, Form,Vue) {

    console.log('vue:',Vue);
    var Controller = {
        index: function () {
            const { createApp,ref} = Vue
            const app = createApp({
                setup(){
                    const message = ref('你好谢谢')
                    return {
                        message
                    }
                }
            });
            app.mount('#app');
        }
    };
    return Controller;
});

前端


<div class="panel panel-default panel-intro">

    <div id="app">
        {{message}}
    </div>
</div>

在这里插入图片描述

相关推荐

  1. fastadmin 导出

    2024-07-16 10:22:01       59 阅读
  2. FastAdmin

    2024-07-16 10:22:01       55 阅读
  3. vue3导入文件夹、导入文件、导出zip、导出

    2024-07-16 10:22:01       52 阅读
  4. vue导入

    2024-07-16 10:22:01       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 10:22:01       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 10:22:01       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 10:22:01       57 阅读
  4. Python语言-面向对象

    2024-07-16 10:22:01       68 阅读

热门阅读

  1. OutOfMemoryError异常OOM排查

    2024-07-16 10:22:01       21 阅读
  2. leetcode热题100.最长递增子序列(动态规划大成)

    2024-07-16 10:22:01       22 阅读
  3. RK3568 安卓12 EC20模块NOCONN没有ip的问题(已解决)

    2024-07-16 10:22:01       22 阅读
  4. C++关键字

    2024-07-16 10:22:01       21 阅读
  5. k8s nacos2.0.3 连接 mysql8.0 提示No Datasource set问题

    2024-07-16 10:22:01       21 阅读