簡體   English   中英

我什么時候應該將代碼放在導出模塊之外,即生命周期掛鈎在單個文件Vue組件中?

[英]When should I put my code outside the export module, lifecycle hooks in a single file Vue component?

我正在編寫一個代碼,該代碼需要計算一些邏輯,例如處理一些數組。

因此,通常,單個文件Vue組件如下所示:

<template>
  ...
</template>

<script>
import ...

// When should I put my code here?

export default {
  created: function() {
    // And what type of code I should put here?
  }    
}
</script>

我應該在什么時候importexport什么類型的代碼?

謝謝!

也許您可以在那里定義一些常數。 像這樣:

const THIS_IS_A_CONSTANT = 'thisIsAConstant'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM