• 9.20总结


    一、VUE脚手架搭建

            1.1下载Node

            1.2下载vue客户端 

            npm install -g @vue/cli 

            更换下载源

            npm config set registry https://registry.npm.taobao.org

             1.3 在命令窗口创建vue项目

            vue create jsd2206-csmall-web-client-teacher

             1.4 用 idea打开vue项目,后加载 element -ui 、axios和node库

        npm i element-ui -S    npm i axios -S     npm install

            1.5 下载完成后,需要在`src/main.js`中添加配置:

    1. import ElementUI from 'element-ui';
    2. import 'element-ui/lib/theme-chalk/index.css';
    3. import axios from 'axios';
    4. Vue.prototype.axios = axios;
    5. Vue.use(ElementUI);

     二、创建vue文件

            vue将页面拆封为视图组件,只需要在一个页面上,调用不同的组件来实现不同的页面。

            2.1启动vue项目

            npm run serve

            2.2添加vue文件

            添加完vue文件后在 src/router/index.js中添加path路径

    1. {
    2. path:'/registerForm',
    3. name:'注册',
    4. component: () => import("../components/operate/Register_Form")
    5. }

    vue脚手架模式下

    this.axios.post(url, this.ruleForm).then((response) => {})

    跨域

    1. 默认情况下,不允许向别的服务提交异步请求,例如,在`http://localhost:9000`服务上,向`http://localhost:8080`提交异步请求,这是不允许的!
    2. 在基于Spring Boot的项目中,要允许跨域访问,可以在启动类上实现`WebMvcConfigurer`接口,并重写`addCorsMappings()`方法:
    3. ```java
    4. @ServletComponentScan
    5. @SpringBootApplication
    6. public class CoolsharkApplication implements WebMvcConfigurer {
    7. public static void main(String[] args) {
    8. SpringApplication.run(CoolsharkApplication.class, args);
    9. }
    10. @Override
    11. public void addCorsMappings(CorsRegistry registry) {
    12. registry.addMapping("/**")
    13. .allowCredentials(true)
    14. .allowedHeaders("*")
    15. .allowedMethods("*")
    16. .allowedOriginPatterns("*")
    17. .maxAge(3600);
    18. }
    19. }

  • 相关阅读:
    剑指 Offer 12. 矩阵中的路径
    BF算法详解(JAVA语言实现)
    PMO制定的流程机制如何落地实施?
    WMS系统后端开发-用户权限
    数据结构——树
    C语言学习书籍 零基础入门篇
    python正则匹配示例
    mysql外键(foreign key)
    [linux] scp 远程拷贝到本地机器
    接口api 之Swagger 一次实战探索
  • 原文地址:https://blog.csdn.net/weixin_51722520/article/details/126956262