<el-table-column property="name" :label="$t('script.table.name')" width="250" fixed…
- User
<template slot-scope="{row}" @click="showScript(row.script)"> {{ row.name || '-'}}
showScript(script: Script) { ScriptModule.updateScriptModals({ ...ScriptModule.scriptModals, ...{ detailsScriptDialog: true, script } }) }
- Assistant
The
el-table-columncomponent is used to define a column in a table. In this case, theel-table-columnhas the following properties:property="name": The property to be displayed in the column, in this case, the "name".:label="$t('script.table.name')": The label for the column, which can be a translated string using the$tmethod.width="250": The width of the column, set to 250 pixels.fixed: The column is fixed in the table, meaning it stays in its position when scrolling horizontally.sortable: The column is sortable, allowing the user to sort the table by this column.
Inside the column, there is a
<template>element with theslot-scopeattribute. This allows the template to access the properties of each row in the table (rowin this case). The@clickevent is bound to this template, so when it is clicked, theshowScriptmethod is called with the as a parameter. - User
<el-table-column property=“name” :label=“$t(‘script.table.name’)” width=“250” fixed sortable
<template slot-scope=“{row}” @click=“showScript(row.script)”> {{ row.name || ‘-’}}
showScript(script: Script) { ScriptModule.updateScriptModals({ …ScriptModule.scriptModals, …{ detailsScriptDialog: true, script } }) } <el-table-column property=“name” :label=“$t(‘script.table.name’)” width=“250” fixed sortable
<template slot-scope=“{row}” @click=“showScript(row.script)”> {{ row.name || ‘-’}}
showScript(script: Script) { ScriptModule.updateScriptModals({ …ScriptModule.scriptModals, …{ detailsScriptDialog: true, script } }) } почему не работает?
- Assistant
Не работает, потому что код скопирован некорректно и содержит неправильные кавычки (
“и”) вместо правильных ("). Вот исправленный код:<el-table-column property="name" :label="$t('script.table.name')" width="250" fixed sortable > <template slot-scope="{row}" @click="showScript(row.script)"> {{ row.name || '-' }} </template> </el-table-column>showScript(script: Script) { ScriptModule.updateScriptModals({ ...ScriptModule.scriptModals, detailsScriptDialog: true, script }) }Проверьте, что вы используете правильные кавычки (
") везде и попробуйте выполнить код ещё раз.