내가 간단한 뷰 구성 요소가 정의되어 단순히 목록 서버 연결 데이터 :이 구성 요소가 설치 될 때 Vuex에서 server
가 이미 정의 및 수행Vuejs 정의되지 않은 속성 오류하지만
<template>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="page-header">
<h2 class="title">Data</h2>
</div>
<br>
</div>
<div class="col-xs-12">
<table class="table">
<tr>
<td>Server</td>
<td><strong>{{config.servers}}</strong></td>
</tr>
<tr>
<td>Port</td>
<td><strong>{{config.port}}</strong></td>
</tr>
<tr>
<td>Description</td>
<td><strong>{{config.description}}</strong></td>
</tr>
<tr>
<td>Protocol</td>
<td :class="{'text-success': isHttps}">
<i v-if="isHttps" class="fa fa-lock"></i>
<strong>{{config.scheme}}</strong>
</td>
</tr>
</table>
</div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Application',
data() {
return {
config: {
scheme: '',
servers: '',
port: '',
description: ''
}
}
},
computed: {
...mapState(['server']),
isHttps:() => this.config.scheme === 'https'
},
mounted() {
const matched = this.server.match(/(https?):\/\/(.+):(\d+)/)
this.config = {
scheme: matched[1],
servers: matched[2],
port: matched[3],
description: window.location.hostname.split('.')[0] || 'Server'
}
}
}
</script>
, 나는 시도하는 경우 console.log(this.server)
으로 변경하면 올바른 URL이 표시됩니다. 이미 configuration
또는 details
처럼, 뭔가 다른 config
을 변경하려고, 심지어 created
에 mounted
을 변경 한
[Vue warn]: Error in render function: "TypeError: Cannot read property 'scheme' of undefined"
found in
---> <Application> at src/pages/Aplicativo.vue
<App> at src/App.vue
<Root>
하지만 오류가 팝업 유지 : 문제는, 내 계산 재산 isHttps
다음과 같은 오류가 발생한다 내 서식 파일은 이 전혀 렌더링되지 않았습니다..
먼저 config
을 계산 된 속성으로 만들기 시작했지만 오류가 이미 내 콘솔로 전달되고 있습니다. 이 같은 계산 된 속성도 없다는 오류가 발생합니다 같은 방법으로 저장소를 사용하여 내 $store
정의되지 않는다 :
server:() => this.$store.state.server
내가 무엇을 할 수 있습니까?
정말 고마워요! –