小编une*_*eer的帖子

加载谷歌地图而不使用回调方法

我在我的网站上有多个谷歌地图实例,现在在同一页面上有两个不同的谷歌地图,会发生什么是第一个工作,而其他现在不知道逻辑问题我先告诉你我的代码

<script>
    function initMap() {
        var myLatLng = {lat: 43.6222102, lng:-79.6694881};

        var map = new google.maps.Map(document.getElementById('map'), {
            zoom: 15,
            center: myLatLng
        });

        var marker = new google.maps.Marker({
            position: myLatLng,
            map: map,
        });
    }
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=my_key&callback=initMap"
        async defer></script>
Run Code Online (Sandbox Code Playgroud)

现在我定义了一个回调方法,它总是初始化名为initMap的方法,而我想做的是可以有多个谷歌地图让我们假设initMap2如何加载它们而不需要回调方法?

javascript google-maps

6
推荐指数
1
解决办法
6471
查看次数

Cookie 未通过 Axios 发送

我有一个基于 Nuxt/vuejs 构建的表单。在 django 的后端,启用了 CSRF 保护,现在需要 Api 中的两件事调用X-CSRFToken作为标头和csrftoken作为 Cookie ,我通过 Postman 调用 Api 来测试 Api,这工作正常,但在 Vue 的情况下它没有通过 post 请求发送 Cookie 让我向您展示我的代码

axios 发布请求

const headers = {
    "X-CSRFToken": "some token",
    "Cookie": "csrftoken=some token",
}
await axios.post(`onboarding/first-name-last-name-email/`, {
    "first_name": "uneeb2",
    "last_name": "sad",
    "email": "asdsa@asd.colm"
}, {
    headers: headers
}, {
    withCredentials: true
})
Run Code Online (Sandbox Code Playgroud)

我也尝试过Fetch是否也有同样的问题

fetch(
  'https://staging.goqube.io/api/onboarding/first-name-last-name-email/',
  { credentials: 'include' ,method: "POST",headers:headers} // could also try ''
).then(res => {
  if (res.ok) return res.json()
  // …
Run Code Online (Sandbox Code Playgroud)

django cookies vue.js axios nuxt.js

6
推荐指数
1
解决办法
1万
查看次数

在 CI 管道中运行开发服务器

我有一个使用 Github Action/Workflows 的 CI 管道设置,我想在其中运行 Cypress 自动化测试,但是我在如何运行我的开发服务器方面遇到了一些逻辑问题。让我向你展示我的管道

name: Nuxt CI Pipeline

on:
  push:
    branches: [ CI-pipeline ]
  # pull_request:
  #   branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [ 14.x ]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - name: Make envfile
      uses: SpicyPizza/create-envfile@v1
      with:
        envkey_ENV: staging
        file_name: .env
    - run: npm ci
    - run: …
Run Code Online (Sandbox Code Playgroud)

continuous-integration vue.js devops nuxt.js github-actions

3
推荐指数
1
解决办法
1216
查看次数