我正在尝试使用组合 API 在 Vue 3 组件中输入提示我的道具。
所以,我这样做:
<script lang="ts">
import FlashInterface from '@/interfaces/FlashInterface';
import { ref } from 'vue';
import { useStore } from 'vuex';
export default {
props: {
message: {
type: FlashInterface,
required: true
}
},
setup(props): Record<string, unknown> {
// Stuff
}
};
Run Code Online (Sandbox Code Playgroud)
我的FlashInterface看起来像这样:
export default interface FlashInterface {
level: string,
message: string,
id?: string
}
Run Code Online (Sandbox Code Playgroud)
除了在这种情况下我收到此错误外,此界面运行良好:
ERROR in src/components/Flash.vue:20:10
TS2693: 'FlashInterface' only refers to a type, but is being used as a value here. …Run Code Online (Sandbox Code Playgroud) 我正在使用Python在本地ElasticSearch(localhost:9200)中添加条目
目前,我使用这种方法:
def insertintoes(data):
"""
Insert data into ElasicSearch
:param data: dict
:return:
"""
timestamp = data.get('@timestamp')
logstashIndex = 'logstash-' + timestamp.strftime("%Y.%m.%d")
es = Elasticsearch()
if not es.indices.exists(logstashIndex):
# Setting mappings for index
mapping = '''
{
"mappings": {
"_default_": {
"_all": {
"enabled": true,
"norms": false
},
"dynamic_templates": [
{
"message_field": {
"path_match": "message",
"match_mapping_type": "string",
"mapping": {
"norms": false,
"type": "text"
}
}
},
{
"string_fields": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"fields": {
"keyword": {
"type": …Run Code Online (Sandbox Code Playgroud) 我有这个关联数组:
lettres['A']=0
…(from 'A' to 'Z')…
lettres['Z']=0
Run Code Online (Sandbox Code Playgroud)
我的问题很简单:如何获取一个元素的值并递增它?我尝试过以下方法:
lettres[$char]=${lettres[$char]}++
Run Code Online (Sandbox Code Playgroud)
但它失败了,因为结果是«0 ++++++++.我怎样才能轻松增加价值?
编辑:更多代码:
while (( i++ < ${#word} )); do
#$char current char
char=$(expr substr "$word" $i 1)
if [[ "${mot[@]}" =~ "${char} " || "${mot[${#mot[@]}-1]}" == "${char}" ]]; then
#char is currently in array $mot -> skipping
echo 'SKIPPING'
else
#Char is not in array $mot -> adding + incrementing lettres
((lettres[char]++))
echo ${lettres[$char]}
#Adding to $mot
mot[${#mot[@]}]=$char
fi
echo "<$char>"
done
Run Code Online (Sandbox Code Playgroud)