随笔分类 -  JS

摘要:view.on("click", (event) => { console.log(event.mapPoint.x); console.log(event.mapPoint.y); }); 阅读全文
posted @ 2021-07-27 10:53 maycpou 阅读(998) 评论(0) 推荐(0)
摘要:我是在使用4.19.3这个版本的时候出现这个问题,其他版本未测试。 就是在设置MapView的center属性的时候,如果你使用的坐标系不是4326那么不能直接按照center:[xxx.xx,xx.xx]的格式设置。 需要先创建一个对应坐标系的点对象,再将这个点对象赋给center: let pt 阅读全文
posted @ 2021-07-27 10:47 maycpou 阅读(276) 评论(0) 推荐(0)
摘要:1.provide用于在根组件中分享自己组件的变量,inject用于在所有根组件的子组件中注册使用根组件中分享出来的变量。 2.正常vue中使用provide和inject: 根组件: <script> export default { name:'root', data(){ return { n 阅读全文
posted @ 2021-07-21 09:01 maycpou 阅读(1482) 评论(0) 推荐(0)
摘要:1.首先setup函数实在beforeCreated之前调用的。所以在setup中没有beforeCreated和created两个生命周期函数。 2.其他的生命周期函数在setup中使用的时候只需要在前面加上一个‘on’即可,如mounted的生命周期函数在setup中写为onMounted 3. 阅读全文
posted @ 2021-07-21 08:35 maycpou 阅读(338) 评论(0) 推荐(0)
摘要:<template> <div class="home"> <button @click="a++">{{ a }}</button> <br /> <button @click="b++">{{ b }}</button> </div> </template> <script> import {  阅读全文
posted @ 2021-07-20 17:14 maycpou 阅读(480) 评论(0) 推荐(0)
摘要:<template> <div class="home"> {{age}} <br> <button @click="add()">change</button> <br> {{nameAndAge}}//页面展示计算属性 </div> </template> <script> import{ref 阅读全文
posted @ 2021-07-20 16:40 maycpou 阅读(341) 评论(0) 推荐(0)
摘要:1.在setup中普通声明的变量,并返回时该变量不是响应式的,即改变该变量的值不会刷新页面。 <template> <div class="home"> {{num}} <br> <button @click="add()">change</button>//这里点击的时候在方法中即使改变了num的 阅读全文
posted @ 2021-07-11 11:15 maycpou 阅读(799) 评论(0) 推荐(0)
摘要:在没有使用setup前的写法中,在methods的方法或者mounted的方法中我们可以用this来获取data数据调用一些方法之类的,this指向当前这个组件。 但是在setup中this是undefined的,因为setup方法的调用时机是在boforeCreated方法之前,也就是说在组件还没 阅读全文
posted @ 2021-07-06 18:28 maycpou 阅读(4376) 评论(0) 推荐(0)
摘要:1.去掉地图边框。默认ui在点击地图后会有一个边框显示出来,且之后会一直存在。 去掉方法是加上样式: .esri-popup__inline-actions-container { display: none; } .esri-view .esri-view-surface--inset-outli 阅读全文
posted @ 2021-07-05 17:10 maycpou 阅读(1467) 评论(0) 推荐(0)
摘要:前面介绍的vue的组件书写中,必须要在data,methons,或者computed等模块中写上对应的内容,vue3提供了一种更加自由的写法,不用非得定义这些各个模块并只能将需要的内容写入固定的模块中,这种写法叫组合API。 如下Home.vue: <template> <div class="ho 阅读全文
posted @ 2021-07-03 12:23 maycpou 阅读(246) 评论(0) 推荐(0)
摘要:如果项目很大再store的index.js里面可能就有很多的内容,不便于管理,vuex支持在主模块下面创建子模块: store/index.js: import { createStore } from 'vuex' //新建一个子模块,也可以将这个子模块写在外面的一个js文件中,这里引入 cons 阅读全文
posted @ 2021-07-03 11:57 maycpou 阅读(879) 评论(0) 推荐(0)
摘要:参考:https://www.bilibili.com/read/cv8965701/ 在vue3项目中测试的一个demo。 npm install @arcgis/core 安装包。 在main.js中全局引入样式:import '@arcgis/core/assets/esri/themes/l 阅读全文
posted @ 2021-06-25 10:40 maycpou 阅读(1043) 评论(0) 推荐(0)
摘要:当前端和后端的地址在同域下时,前端调用后端的接口不算跨域,不会出现跨域问题。同域要求地址和端口都一样。然后/后面的路径可以不一样。 为什么出现跨域问题。所谓的跨域问题就是当前端访问和自己不是同域的接口的时候报错的问题。 那么为什么会报错,是因为这种行为被浏览器禁止了,也就是和后端没有关系,是浏览器就 阅读全文
posted @ 2021-06-07 17:28 maycpou 阅读(137) 评论(0) 推荐(0)
摘要:正常使用provide的方式: 父组件中: provide:{ for:'demo' } 这样子组件中无论多深的子组件都可以使用:inject:['for'], data(){ return{ demo:this.for } } 但是上面的写法有一定的问题,比如父组件中for变量的值如果我们是在mo 阅读全文
posted @ 2021-06-07 11:26 maycpou 阅读(1914) 评论(0) 推荐(0)
摘要:let layerUrl = "http://xxx.xxx.xx.xx/server/rest/services/xxxx/xxxx/MapServer/194";//服务地址 let queryTask = new this.esriModules.QueryTask(layerUrl);//创 阅读全文
posted @ 2021-06-01 14:58 maycpou 阅读(807) 评论(0) 推荐(0)
摘要:var tileLayer = new VectorTileLayer({ url: "http://xxx.xxx.xx.xx/server/rest/services/Hosted/xxx/styles/root.json",//服务地址 }); this.map.add(tileLayer); 阅读全文
posted @ 2021-06-01 14:35 maycpou 阅读(459) 评论(2) 推荐(0)
摘要:1.带后缀名 function getFileName(path){ var pos1 = path.lastIndexOf('/'); var pos2 = path.lastIndexOf('\\'); var pos = Math.max(pos1, pos2) if( pos<0 ) ret 阅读全文
posted @ 2021-05-31 12:11 maycpou 阅读(3170) 评论(0) 推荐(0)
摘要:一个比较简单的解决方式是:将代码中输入的空格换成全角的。 阅读全文
posted @ 2021-05-31 12:08 maycpou 阅读(1163) 评论(0) 推荐(0)
摘要:draw() { this.view.container .querySelector(".esri-view-root > .esri-view-surface") .setAttribute("data-cursor", "crosshair");//设置鼠标的样式变为十字架 let graph 阅读全文
posted @ 2021-05-26 17:19 maycpou 阅读(488) 评论(0) 推荐(0)
摘要:Arcgisapi for js中提供了一个BasemapToggle专门用于底图的切换。 mounted() { loadArcgisApiForJs().then((esriModules) => {//esriload加载Arcgisapi for js模块 this.esriModules  阅读全文
posted @ 2021-05-26 10:29 maycpou 阅读(774) 评论(0) 推荐(0)