querystring을 받아왔는데 JavaScript get 방식으로 값을 받아오는 방법

 

// Query String 데이터 출력
function searchParam(key) { // key를 매개변수로 받고, value를 리턴
		return new URLSearchParams(location.search).get(key)
}

함수로 생성해놓고 사용하는 것이 편합니다.

 // url =  www.example.com?page=12
 const page = searchParam('page')
 console.log(page)       // 12 출력

 

key: value 형태이다보니, key 값을 매개변수로 넘겨주어야 value가 출력됩니다.

반응형

다양한 오늘날짜를 출력하는 방법 중에서

20211122포맷을 출력하는 방법

함수로 선언하기

function getTodayDate () {
            const todayDate = new Date()
            const year = todayDate.getFullYear()
            const months = todayDate.getMonth()+1
            const days = todayDate.getDate()
            const resultDate = year + '' + months + '' + days
            return resultDate
        }

// resultDate의 값이 반환됩니다.
getTodayDate()

 

그냥 선언하기

const todayDate = new Date()
const year = todayDate.getFullYear()
const months = todayDate.getMonth()+1
const days = todayDate.getDate()
const resultDate = year + '' + months + '' + days

//아래 결과 : 20211122
console.log(resultDate)

 

반응형

Linux, Ubuntu, Vue-cli, axios를 사용하는데, proxy 에러가 출력되었다.

Proxy error: Could not proxy request 

 

 

 

■ 해결 방법

해당 에러는 root 경로vue.config.js 에서 proxy 관련 정보를 수정하면 된다.

/vue.config.js

module.exports = {
  devServer: {
    proxy: {
      "/api": {
        target: "https://localhost:8081/",
      },
    },
}

 

기본 경로(/root)가 될 port 번호정보를 작성하면 된다.

 

이제는 path 문제가 남았습니다.....

 

proxy 문제가 해결된것을 확인하실 수 있습니다.

이렇게 axios를 이용해서 데이터를 올바른 경로에서 뽑아오면 되겠습니다.

 

 

 

 

Form Handling | Cracking Vue.js

Form 다루기 폼(Form)은 웹 애플리케이션에서 가장 많이 사용되는 코드 형식입니다. 로그인이나 상품 결제 등 모든 곳에 사용자의 입력을 처리하는 폼이 필요합니다. Form 제작하기 그럼 뷰로 간단

joshua1988.github.io

 

vue proxy 사용하기

vue cli 3.x 버전 이상에서 웹팩 개발서버를 이용해서 프록시 요청을 보내봅시다.

velog.io

 

 

 

반응형

 

Vue.js 3 + bootstrap이 되지 않아 Vuetify를 설치하려고 하였다. 그러나,,,

Vue.js 3 - Vuetify 를 설치하던 와중 에러 발생.

 

ㅎㅎ;;

Error: You cannot call "get" on a collection with no paths. Instead, check the "length" property first to verify at least 1 path exists.
    at Collection.get (/usr/local/lib/node_modules/@vue/cli/node_modules/jscodeshift/src/Collection.js:213:13)
    at injectOptions (/usr/local/lib/node_modules/@vue/cli/lib/util/codemods/injectOptions.js:15:6)
    at runTransformation (/usr/local/lib/node_modules/@vue/cli/node_modules/vue-codemod/dist/src/runTransformation.js:60:17)
    at /usr/local/lib/node_modules/@vue/cli/lib/Generator.js:290:23
    at Array.forEach (<anonymous>)
    at Generator.resolveFiles (/usr/local/lib/node_modules/@vue/cli/lib/Generator.js:276:24)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Generator.generate (/usr/local/lib/node_modules/@vue/cli/lib/Generator.js:175:5)
    at async runGenerator (/usr/local/lib/node_modules/@vue/cli/lib/invoke.js:111:3)
    at async invoke (/usr/local/lib/node_modules/@vue/cli/lib/invoke.js:92:3)

이렇게 또 에러가 발생하였다.

 

에러 원인 : "아직 지원을 하지 않는다?"

예. 또 지원을 안합니다. (vue3 어따가 써먹냐)

다운그레이드(down grade)를 하던가 다른 css framework를 사용하던가 해야하는데, 뭐가 남았을까용?

tailwind는 되나 실행해보러 갑니다.

 

ㅎㅎ ㅈㅅ;;

 

 

 

Get started with Vuetify

Get started with Vue and Vuetify in no time. Support for Vue CLI, Webpack, Nuxt and more.

vuetifyjs.com

 

 

Errors while doing vue add vuetify(vue3 preview)

I tried to start a vue3 project with vuecli, but when I add vuetify, errors occurred while everything is normal when used vue2. It says Error: You cannot call "get" on a collection with no

stackoverflow.com

 

 

반응형

+ Recent posts