打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模板:Str left/doc

来自Tiancheng Wiki
WikiAdmin留言 | 贡献2025年11月25日 (二) 16:21的版本 (导入1个版本:​从Wikipedia导入)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

{{#if:

|

{{#if:x| | }} | {{#switch:doc| {{{override}}}| doc | Doc | documentation | Documentation | 文档 | 文件 = {{#ifeq:show| show|

}}{{#if:| | [[Category:{{#switch:模板|User=用户|Wikipedia=维基百科|Template=模板}}说明文件]]}}}}

}}

{{safesubst:#if:

|
|{{safesubst:#if:{{safesubst:#if:
|
|{{safesubst:#if:
 |
 |
}}

}}

 |
 |
}}

}}

本模板用于截取字符串的前n个字符。

使用方式

<syntaxhighlight lang="wikitext"></syntaxhighlight>

  • |{{#if:1|1=}} — 待截取的字符串
  • |{{#if:2|2=}} — 截取的字数(默认为1)

例子

  • <syntaxhighlight lang="wikitext" inline>底事崑崙傾砥柱</syntaxhighlight> → 底事崑崙傾砥柱
  • <syntaxhighlight lang="wikitext" inline>一</syntaxhighlight> →

模板數據

{{#if:| |以下是该模板的{{#if:|-{zh-cn:模板数据;zh-tw:模板資料}-|-{zh-cn:模板数据;zh-tw:模板資料}-}},适用于-{zh-cn:可视化编辑器;zh-tw:視覺化編輯器;}-等工具。}}

Str left-{zh-cn:模板数据;zh-tw:模板資料}-

{{#ifeq:doc|sandbox||

}} <templatedata> { "description": "顯示一串文字中的前幾個字", "params": { "1": { "label": "文字串", "description": "需要計算字數裁切的文字內容", "required": true, "type": "string" }, "2": { "label": "長度", "description": "希望顯示的字數", "required": true, "type": "number" } } } </templatedata>