Vue模板如何禁止控制台登录?

起源$log:


Vue.prototype.$log = console.log

禁止场所:


<template>

  <!-- Place 1 -->

  <div @click="$log">

    <!-- Place 2 -->

    {{ $log }}

    <!-- Place 3 -->

    {{ $log('foo') }}

  </div>

</template>


<script>

import Vue from 'vue'


// Place 4

Vue.prototype.$log('foo')


export default {

  created() {

    // Place 5

    this.$log('foo')

  },

}

</script>


慕的地10843
浏览 75回答 1
1回答

呼唤远方

在深入研究no-restricted-syntax、vue/no-restricted-syntax规则和ASTs 之后,我终于开始工作了,以下是工作规则:{&nbsp; rules: {&nbsp; &nbsp; 'no-restricted-syntax': [&nbsp; &nbsp; &nbsp; 'error',&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; selector: '[name=$log]',&nbsp; &nbsp; &nbsp; &nbsp; message: "Using '$log' is not allowed.",&nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; ],&nbsp; &nbsp; 'vue/no-restricted-syntax': [&nbsp; &nbsp; &nbsp; 'error',&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; selector: '[name=$log]',&nbsp; &nbsp; &nbsp; &nbsp; message: "Using '$log' is not allowed.",&nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; ],&nbsp; },}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript