当前位置: 首页 > news >正文

金昌做网站云服务器做的网站需要备案

金昌做网站,云服务器做的网站需要备案,西宁专业做网站的,做APP好还是建设网站好配置 router和vuex需要在创建vue项目的时候#xff0c;开始的时候选择Manually select features#xff0c;于是就可以在下一个创建配置讯问中选择router和vuex。 axios则需要执行命令行#xff1a; npm install axios -S 之后再在需要发送请求的view导入即可。 router…配置 router和vuex需要在创建vue项目的时候开始的时候选择Manually select features于是就可以在下一个创建配置讯问中选择router和vuex。 axios则需要执行命令行 npm install axios -S 之后再在需要发送请求的view导入即可。 router实现左边点击右边打开 首先需要安装ElementUI方法见day4 vue2以及ElementUI-CSDN博客。 在App.vue中导入框架将nav、router-view标签移动到对应位置。其中to配置相当于servlet请求的路径。 templatediv idappel-containerel-header欢迎你/el-headerel-containerel-aside width200pxnavullirouter-link to/Home/router-link/lilirouter-link to/aboutAbout/router-link/lilirouter-link to/question问题管理/router-link/lilirouter-link to/new新页面/router-link/li/ul/nav/el-asideel-mainrouter-view//el-main/el-container/el-container/div /templatestyle #app {font-family: Avenir, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50; }nav {padding: 30px; }nav a {font-weight: bold;color: #2c3e50; }nav a.router-link-exact-active {color: #42b983; } /style并在router的 index.js中配置请求路径对应的view们相当于web.xml。其中有两种方式导入view第一种可以直接开头import在routers中的component中就只用写出你的模块名即可这是静态导入其实相当于js中的include编译指令开始就导入自然加载速度会变快但是动态导入往往常见一些就比如这里可以直接在component中 ()import (路径)这样是动态导入请求该view的时候才会加载更灵活。 import Vue from vue import VueRouter from vue-router import HomeView from ../views/HomeView.vue // 路由的配置 Vue.use(VueRouter)const routes [{path: /,name: home,component: HomeView},{path: /about,name: about,// route level code-splitting// this generates a separate chunk (about.[hash].js) for this route// which is lazy-loaded when the route is visited.component: () import(/* webpackChunkName: about */ ../views/AboutView.vue)},{path:/question,name:question,component:() import(/* webpackChunkName: about */ ../views/QuestionView.vue)},{path:/new,name:new,component:() import(/* webpackChunkName: about */ ../views/NewView.vue)} ] // js文件中导出一个 router 实例 const router new VueRouter({routes })export default router使用vuex处理用户的动作 vuex主要往外导出五个属性在store的index.js中state用于储存页面共享的数据actions用于处理发出的动作mutations用于直接操纵state中的数据getters中对state中的数据进行再次加工类似vue中计算属性computed。 就如图片中一样view中用dispatch发出动作actions使用commit将动作处理转给mutations对state进行直接操作前端可以直接调用state中的数据来实现数据更新。getters的处理则直接可以前端执行{{$store.getters.方法名}}。 store中的index.js import Vue from vue import Vuex from vuexVue.use(Vuex)export default new Vuex.Store({state: {// 共享数据count: 0, // 初值为零myNewList:[]},getters: { // 对state中的数据进行再次加工类似vue中计算属性computedupdate(state) {return state.count * 10;}},mutations: { // 修改state数据change(state, value) {state.count value;},sub(state, value) {state.count - value;}},actions: { // 相应动作处理// 必须与dispatch中的时间名一致sum(context, value) {context.commit(change, value);},sub(context, value) {context.commit(sub, value);}},modules: { // 分模块化开发一个模块可以有自己的stategettersmutationsactions} })前端调用 templatediv classabouth1This is an about page/h1h2当前计算的和为{{$store.state.count}}/h2h2当前计算的和 ✖ 10 为{{$store.getters.update}}/h2el-button clickadd typeprimary round我猜你不会点击我/el-buttonbr/br/el-button clicksub typeprimary round我可以回去哦/el-button/div /template script export default{name: AboutView,methods:{// 求和时间处理add(){// 进行dispatchthis.$store.dispatch(sum,5);},sub(){this.$store.dispatch(sub,10);}} } /script 使用axios实现前后端连接 其原理是可以使用axios访问不同端口向不同端口发送请求有两种方式发送请求 可以直接在view中导入axios包直接发送请求但是因为请求的地址往往容易变化所以需要用第二种方式来发送请求首先在util包中创建js页面配置baseUrl在此导入axios包也就是端口号然后在api包中创建针对不同view的不同请求url也就是请求的具体地址和请求方法以及可能的参数将方法配置可以其他文件访问export default这时候就需要将配置好的js文件直接导入到view中然后再调用方法即可。 url在view中第一种 templatediv classhomeimg altVue logo src../assets/logo.png /HelloWorld msgWelcome to Your Vue.js App /br/el-button clicksendRequest() typeprimary发送axios请求进行调用springboot项目/el-buttonbr/br/br/el-table :datathis.$store.state.myNewList border stylewidth: 100%el-table-column fixed propid label编号 width150/el-table-columnel-table-column propexpertName label专家姓名 width120 /el-table-columnel-table-column propquestioner label提问人 width120/el-table-columnel-table-column propphone label电话 width120 /el-table-columnel-table-column propplantName label农作物名称 width300/el-table-columnel-table-column propquestion label问题 width120 /el-table-columnel-table-column propanswer label回答 width120 /el-table-columnel-table-column propstatus label状态 width120 /el-table-columnel-table-column fixedright label操作 width100template slot-scopescopeel-button clickhandleClick(scope.row) typetext sizesmall查看/el-buttonel-button typetext sizesmall编辑/el-button/template/el-table-column/el-table/div /templatescript // is an alias to /src import HelloWorld from /components/HelloWorld.vue; import axios from axios; // 引入axios库export default {name: HomeView,components: {HelloWorld,},methods: {sendRequest() {axios.get(http://localhost:8888/question/findAll).then(response {this.questonList response.data.data;this.$store.state.myNewList response.data.data;});},},data(){return {questonList: []}} }; /scripturl在js文件中第二种 templatediv classhomeimg altVue logo src../assets/logo.png /br /el-button clicksearch typeprimarysearch/el-buttonel-button clickadd() typeprimaryadd/el-buttonbr /br /br /el-input v-modelinputValue placeholder请输入id或专家姓名/el-inputbr /br /el-table :dataquestionList border stylewidth: 100%el-table-column fixed propid label编号 width150/el-table-columnel-table-column propexpertName label专家姓名 width120/el-table-columnel-table-column propquestioner label提问人 width120/el-table-columnel-table-column propphone label电话 width120 /el-table-columnel-table-column propplantName label农作物名称 width300/el-table-columnel-table-column propquestion label问题 width120/el-table-columnel-table-column propanswer label回答 width120/el-table-columnel-table-column propstatus label状态 width120/el-table-columnel-table-column fixedright label操作 width100template slot-scopescopeel-button clickhandleClick(scope.row) typetext sizesmall删除/el-buttonel-button typetext sizesmall编辑/el-button/template/el-table-column/el-table/div /templatescript // is an alias to /src import queApi from /api/question; // 导入封装后的axios请求具体见src/api/question.jsexport default {name: HomeView,methods: {sendRequest() {queApi.getQuestionList().then((res) {this.questionList res.data.data;this.$store.state.myNewList this.questionList; // 数据共享});}},data() {return {questionList: [],inputValue: ,};}, }; /scriptapi文件中配置 import request from ../utils/request; // 导入axios实例/*** 调用boot端进行/question/findAll查询* returns {Promise}*/ function getQuestionList() { // 获取问题列表return request({url: /question/findAll,method: get}); }export default {getQuestionList, // 导出函数 } // 导出对象 除了findAll方法之外还可以其他方法 后端 注意axios支持get、post、put、delete等请求所以可以直接按照swagger的请求规范做还有一点要注意需要配置后端可以接受并处理其他端口发出的各种请求也就需要配置CorsConfig文件 package com.zheng.config;import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;Configuration public class CorsConfig implements WebMvcConfigurer {Overridepublic void addCorsMappings(CorsRegistry registry) {// 添加映射路径registry.addMapping(/**)// .allowedOrigins(*) //.allowedOriginPatterns(*) //允许哪些域的请求星号代表允许所有.allowedMethods(POST, GET, PUT, OPTIONS, DELETE) // 允许的方法.allowedHeaders(*) // 允许的头部设置.allowCredentials(true) // 是否发送cookie.maxAge(168000); // 预检间隔时间}}除此之外如果发送的是post、put请求也就是要将传递的参数放到请求体中的需要在获得形参之前加RequestBody才能将传递的参数和需要的参数一一对应。 package com.zheng.controller;import com.zheng.entity.Question; import com.zheng.model.Result; import com.zheng.service.QuestionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;import java.util.List;/*** Controller整合Swagger*/ RestController RequestMapping(/question) Tag(namequestion,description tb_question控制层) // swagger标签 public class QuestionController {Autowiredprivate QuestionService questionService;Operation(description question查询全部) // swagger 标签GetMapping(/findAll) // public ListQuestion findAll() { // return questionService.findAll(); // }public ResultListQuestion findAll() {return Result.ok(questionService.findAll());}/*** findById?id10* param id* return*/Operation(description question根据主键查询) // swagger 标签GetMapping(findById) // public Question findById(RequestParam(id) int id) { // return questionService.findById(id); // }public ResultQuestion findById(RequestParam(id) int id) {return Result.ok(questionService.findById(id));}Operation(description 根据专家名字查询)GetMapping(/findByExpertName/{expertName})public ResultListQuestion findByExpertName(PathVariable(expertName) String expertName) {return Result.ok(questionService.findByExpertName(expertName));}PostMapping(/save)Operation(description 添加question)public ResultInteger save(RequestBody Question question) {return Result.ok(questionService.save(question));}PutMapping(/update) // 修改只能用put请求删除只能用delete请求Operation(description 修改question)public ResultInteger update(Question question) {return Result.ok(questionService.update(question));}/*** /delete/10* param id* return*/DeleteMapping(/delete/{qid})Operation(description 按照编号删除question)public ResultInteger delete(PathVariable(qid) int id) {return Result.ok(questionService.delete(id));} }一个好习惯是将返回的数据封装成一个ResultT类这也相当于一个特殊的实体类来处理这样当面对不同的数据类型的时候才能正常处理 package com.zheng.model;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString;Data NoArgsConstructor AllArgsConstructor ToString public class ResultT {private Integer code; // 编码 200 404 500private String msg; // 消息内容private T data; // 真正的数据public Result(Integer code, T data) {this.code code;this.data data;}public Result(String msg, T data) {this.msg msg;this.data data;}public Result(T data){this.data data;}public staticT ResultT ok(T data){return new Result(200,success,data);}public staticT ResultT fail(Integer code){return new Result(500,fail,null);} }前端 对于前端如何链接这么多方法呢 如果是get、delete请求并将传递的参数直接拼接在路径中而非键值对的形式那么在前端也可以直接拼接在url中不能使用参数params否则404 function findByExpertName(expertName) {return request({url:/question/findByExpertName/ expertName,method:get}) } 对于post请求可以直接这样传递参数在控制层是直接接受一个对象的类型所以传入的也是一个对象类型直接使用data列出要传递的参数即可对于get、delete请求参数必须params而post、put请求必须data传递数据 function addQuestion(data) { // 新增问题return request({url: /question/save,method: post, // post 请求执行添加操作data: data // 发送数据}) } 最后做的小项目实现findById以及findByExpertName以及add方法 templatediv classhomeimg altVue logo src../assets/logo.png /br /el-button clicksearch typeprimarysearch/el-buttonel-button clickadd() typeprimaryadd/el-buttonbr /br /br /el-input v-modelinputValue placeholder请输入id或专家姓名/el-inputbr /br /el-table :dataquestionList border stylewidth: 100%el-table-column fixed propid label编号 width150/el-table-columnel-table-column propexpertName label专家姓名 width120/el-table-columnel-table-column propquestioner label提问人 width120/el-table-columnel-table-column propphone label电话 width120 /el-table-columnel-table-column propplantName label农作物名称 width300/el-table-columnel-table-column propquestion label问题 width120/el-table-columnel-table-column propanswer label回答 width120/el-table-columnel-table-column propstatus label状态 width120/el-table-columnel-table-column fixedright label操作 width100template slot-scopescopeel-button clickhandleClick(scope.row) typetext sizesmall删除/el-buttonel-button typetext sizesmall编辑/el-button/template/el-table-column/el-table!-- 添加的对话框--el-dialog title问题信息 :visible.syncdialogFormVisibleel-form :modelform :rulesrules refquestionFormel-form-itemlabelexpertName:label-widthformLabelWidthpropexpertNameel-input v-modelform.expertName autocompleteoff/el-input/el-form-itemel-form-itemlabelquestioner:label-widthformLabelWidthpropquestionerel-input v-modelform.questioner autocompleteoff/el-input/el-form-itemel-form-item labelphone :label-widthformLabelWidth propphoneel-input v-modelform.phone autocompleteoff/el-input/el-form-itemel-form-itemlabelplantName:label-widthformLabelWidthpropplantNameel-input v-modelform.plantName autocompleteoff/el-input/el-form-itemel-form-item labeltitle :label-widthformLabelWidth proptitleel-input v-modelform.title autocompleteoff/el-input/el-form-itemel-form-itemlabelquestion:label-widthformLabelWidthpropquestionel-input v-modelform.question autocompleteoff/el-input/el-form-itemel-form-itemlabelanswer:label-widthformLabelWidthpropanswerel-input v-modelform.answer autocompleteoff/el-input/el-form-itemel-form-itemlabelstatus:label-widthformLabelWidthpropstatusel-input v-modelform.status autocompleteoff/el-input/el-form-item/el-formdiv slotfooter classdialog-footerel-button clickcancel取 消/el-buttonel-button typeprimary clicksave保 存/el-button/div/el-dialog/div /templatescript // is an alias to /src import queApi from /api/question; // 导入封装后的axios请求具体见src/api/question.jsexport default {name: HomeView,methods: {sendRequest() {queApi.getQuestionList().then((res) {this.questionList res.data.data;this.$store.state.myNewList this.questionList;});},isNumber(value) {return /^\d$/.test(value) value ! ;},search() {if (this.inputValue ) {this.sendRequest();} else {if (this.isNumber(this.inputValue)) {this.findById();} else {this.findByExpertName();}}// this.sendRequest();},findById() {queApi.findById(this.inputValue).then((res) {this.question res.data.data;if (this.question ! null) {this.$set(this, questionList, []); // 清空原有数据this.questionList.push(this.question);} else {alert(未查询到数据);}});},add() {this.dialogFormVisible true;},cancel() {this.dialogFormVisible false;this.form {expertName: ,questioner: ,phone: ,plantName: ,title: ,question: ,answer: ,status: ,};},save() {// 验证表单this.$refs.questionForm.validate((validate) {if (validate) {// 验证通过可以提交数据// alert(this.form.expertName);queApi.addQuestion(this.form).then((res) {if (res.data.code 200) {alert(添加了 res.data.data 条数据);this.sendRequest();} else {alert(res.data.msg);}});this.dialogFormVisible false;this.form {expertName: ,questioner: ,phone: ,plantName: ,title: ,question: ,answer: ,status: ,};}});},findByExpertName() {queApi.findByExpertName(this.inputValue).then((res) {if (res.data.data null) {alert(未查询到数据);} else {this.questionList res.data.data;}});},},data() {return {questionList: [],question: {},inputValue: ,dialogFormVisible: false, // 控制添加的对话框是否可见form: {expertName: ,questioner: ,phone: ,plantName: ,title: ,question: ,answer: ,status: ,},formLabelWidth: 100px,rules: {expertName: [{ required: true, message: 请输入专家姓名, trigger: blur },],questioner: [{ required: true, message: 请输入提问人, trigger: blur },],phone: [{ required: true, message: 请输入电话, trigger: blur },// {// pattern: /^1[34578]\d{9}$/,// message: 请输入正确的手机号,// trigger: blur,// },],plantName: [{ required: true, message: 请输入农作物名称, trigger: blur },],title: [{ required: true, message: 请输入标题, trigger: blur }],question: [{ required: true, message: 请输入问题, trigger: blur }],answer: [{ required: true, message: 请输入回答, trigger: blur }],status: [{ required: true, message: 请输入状态, trigger: blur }],},};}, }; /script
文章转载自:
http://www.morning.jkzjs.cn.gov.cn.jkzjs.cn
http://www.morning.jltmb.cn.gov.cn.jltmb.cn
http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn
http://www.morning.gprzp.cn.gov.cn.gprzp.cn
http://www.morning.mnqg.cn.gov.cn.mnqg.cn
http://www.morning.yktwr.cn.gov.cn.yktwr.cn
http://www.morning.ftdlg.cn.gov.cn.ftdlg.cn
http://www.morning.phlwj.cn.gov.cn.phlwj.cn
http://www.morning.bpmfr.cn.gov.cn.bpmfr.cn
http://www.morning.jzyfy.cn.gov.cn.jzyfy.cn
http://www.morning.drspc.cn.gov.cn.drspc.cn
http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn
http://www.morning.fnxzk.cn.gov.cn.fnxzk.cn
http://www.morning.fqpgf.cn.gov.cn.fqpgf.cn
http://www.morning.kxmyj.cn.gov.cn.kxmyj.cn
http://www.morning.rhjhy.cn.gov.cn.rhjhy.cn
http://www.morning.hnpkr.cn.gov.cn.hnpkr.cn
http://www.morning.qlhkx.cn.gov.cn.qlhkx.cn
http://www.morning.xsklp.cn.gov.cn.xsklp.cn
http://www.morning.shinezoneserver.com.gov.cn.shinezoneserver.com
http://www.morning.rnmyw.cn.gov.cn.rnmyw.cn
http://www.morning.rrxmm.cn.gov.cn.rrxmm.cn
http://www.morning.ykqbs.cn.gov.cn.ykqbs.cn
http://www.morning.ygbq.cn.gov.cn.ygbq.cn
http://www.morning.kmprl.cn.gov.cn.kmprl.cn
http://www.morning.blfll.cn.gov.cn.blfll.cn
http://www.morning.knlyl.cn.gov.cn.knlyl.cn
http://www.morning.wsgyq.cn.gov.cn.wsgyq.cn
http://www.morning.ndlww.cn.gov.cn.ndlww.cn
http://www.morning.kyjpg.cn.gov.cn.kyjpg.cn
http://www.morning.lynb.cn.gov.cn.lynb.cn
http://www.morning.ghwtn.cn.gov.cn.ghwtn.cn
http://www.morning.rpwck.cn.gov.cn.rpwck.cn
http://www.morning.hkshy.cn.gov.cn.hkshy.cn
http://www.morning.zcqbx.cn.gov.cn.zcqbx.cn
http://www.morning.kuaijili.cn.gov.cn.kuaijili.cn
http://www.morning.qzxb.cn.gov.cn.qzxb.cn
http://www.morning.cnprt.cn.gov.cn.cnprt.cn
http://www.morning.slmbg.cn.gov.cn.slmbg.cn
http://www.morning.frsxt.cn.gov.cn.frsxt.cn
http://www.morning.dpdns.cn.gov.cn.dpdns.cn
http://www.morning.bzgpj.cn.gov.cn.bzgpj.cn
http://www.morning.kfyqd.cn.gov.cn.kfyqd.cn
http://www.morning.krdb.cn.gov.cn.krdb.cn
http://www.morning.tjndb.cn.gov.cn.tjndb.cn
http://www.morning.wfcqr.cn.gov.cn.wfcqr.cn
http://www.morning.mqmxg.cn.gov.cn.mqmxg.cn
http://www.morning.hhnhb.cn.gov.cn.hhnhb.cn
http://www.morning.mprky.cn.gov.cn.mprky.cn
http://www.morning.wbfly.cn.gov.cn.wbfly.cn
http://www.morning.tsdqr.cn.gov.cn.tsdqr.cn
http://www.morning.nqpy.cn.gov.cn.nqpy.cn
http://www.morning.hdwjb.cn.gov.cn.hdwjb.cn
http://www.morning.zqbrw.cn.gov.cn.zqbrw.cn
http://www.morning.pjtnk.cn.gov.cn.pjtnk.cn
http://www.morning.srnth.cn.gov.cn.srnth.cn
http://www.morning.ydgzj.cn.gov.cn.ydgzj.cn
http://www.morning.lcmhq.cn.gov.cn.lcmhq.cn
http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn
http://www.morning.ssxlt.cn.gov.cn.ssxlt.cn
http://www.morning.ymbqr.cn.gov.cn.ymbqr.cn
http://www.morning.fmkjx.cn.gov.cn.fmkjx.cn
http://www.morning.beeice.com.gov.cn.beeice.com
http://www.morning.drggr.cn.gov.cn.drggr.cn
http://www.morning.ptslx.cn.gov.cn.ptslx.cn
http://www.morning.kqgqy.cn.gov.cn.kqgqy.cn
http://www.morning.tymnr.cn.gov.cn.tymnr.cn
http://www.morning.pqnps.cn.gov.cn.pqnps.cn
http://www.morning.btwrj.cn.gov.cn.btwrj.cn
http://www.morning.kwpnx.cn.gov.cn.kwpnx.cn
http://www.morning.kqhlm.cn.gov.cn.kqhlm.cn
http://www.morning.jgmdr.cn.gov.cn.jgmdr.cn
http://www.morning.brps.cn.gov.cn.brps.cn
http://www.morning.bbjw.cn.gov.cn.bbjw.cn
http://www.morning.zlwg.cn.gov.cn.zlwg.cn
http://www.morning.npcxk.cn.gov.cn.npcxk.cn
http://www.morning.rbkgp.cn.gov.cn.rbkgp.cn
http://www.morning.jtybl.cn.gov.cn.jtybl.cn
http://www.morning.xfhms.cn.gov.cn.xfhms.cn
http://www.morning.ztjhz.cn.gov.cn.ztjhz.cn
http://www.tj-hxxt.cn/news/271440.html

相关文章:

  • WordPress文章id连号芜湖seo网站优化
  • 网站开发的要注意基本原则云服务器拿来做网站
  • 专做运动品牌的网站营销型网站应必备的七大功能
  • 青海省交通建设管理局网站清远市seo广告优化
  • 网站图片上的分享怎么做用ps给旅游网站做前端网页
  • 重庆梁平网站建设公司平昌县住房和城乡建设局网站
  • 中国网站建设的利弊wordpress动态cdn
  • 黑龙江营商环境建设局网站做网站总结体会
  • 成都搭建企业网站网站怎么做seo_
  • 企业做网站报价试析媒体网站品牌建设
  • 免费网站建设价格费用flash做ppt的模板下载网站有哪些
  • 网站域名审核时间学校网站建设总结报告
  • 企业网站建设方案 ppt公司门户网站的设计与实现
  • 宜宾做网站host wordpress
  • 织梦可以做移动网站吗自己的品牌怎么做加盟推广
  • 网站安全检测方法合同管理软件
  • 设计网站推广方案世界500强企业名单
  • 聊城高端网站建设价格wordpress文章调用链接
  • 做网站域名还重要吗北京网站建设公司华网制作作
  • 自己做网站要多少钱建站工具 开源
  • 请打开123720的网站百度在国外做购物网站
  • 哪个网站比较好wordpress后台乱了是怎么回事
  • 如何建网站免费建设银行企业网站
  • 海南做网站的公司有哪些提升学历官网
  • 建站行业最新消息在吗做网站商城
  • 淄博市建设业协会网站奉贤做网站
  • flash型网站wordpress博客 手机网页 wap
  • 网站创建时间查询网站首页被k 做跳转
  • 乐清网站艰涩纯文字logo在线制作
  • 深圳网站建设 设计首选深圳市杭州建设银行网站首页