text: (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{210:function(t,s,a){"use strict";a.r(s);var r=a(2),e=Object(r.a)({},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"error"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error","aria-hidden":"true"}},[t._v("#")]),t._v(" @error")]),t._v(" "),a("vp-ad-top"),t._v(" "),a("p",[t._v("在编写接受参数的"),a("router-link",{attrs:{to:"/api/AtRules/MixinAndinclude.html"}},[t._v("mixin")]),t._v("和"),a("router-link",{attrs:{to:"/api/AtRules/Function.html"}},[t._v("函数")]),t._v("时，您通常希望确保这些参数具有API所期望的类型和格式。如果没有，则需要通知用户，并且mixin/函数停止运行。")],1),t._v(" "),a("p",[t._v("Sass使用"),a("code",[t._v("@error规则")]),t._v("（格式为"),a("code",[t._v("@error <expression>")]),t._v("）简化了这一点。它打印"),a("router-link",{attrs:{to:"/api/Syntax/Structure.html#表达式"}},[t._v("表达式")]),t._v("（通常是字符串）的值，以及指示如何调用当前mixin或函数的堆栈跟踪。一旦打印出错误，Sass将停止编译样式表，并告诉运行它的系统发生了错误。")],1),t._v(" "),a("el-tabs",{attrs:{type:"border-card"}},[a("el-tab-pane",{attrs:{label:"SCSS"}},[a("div",{staticClass:"language-scss extra-class"},[a("pre",{pre:!0,attrs:{class:"language-scss"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("@mixin")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("reflexive-position")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("@if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token selector"}},[a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" != left and "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" != right ")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token atrule"}},[a("span",{pre:!0,attrs:{class:"token rule"}},[t._v("@error")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Property #{$property} must be either left or right."')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n  "),a("span",{pre:!0,attrs:{class:"token property"}},[a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("if")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" right"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" initial"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token property"}},[a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("if")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" right"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" initial"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n  "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("left")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("right")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  [dir=rtl] &")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("left")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("right")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token selector"}},[t._v(".sidebar ")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("@include")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("reflexive-position")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("top"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" 12px"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Error: Property top must be either left or right.")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])])]),t._v(" "),a("el-tab-pane",{attrs:{label:"Sass"}},[a("div",{staticClass:"language-sass extra-class"},[a("pre",{pre:!0,attrs:{class:"language-sass"}},[a("code",[a("span",{pre:!0,attrs:{class:"token atrule-line"}},[a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("@mixin")]),t._v(" reflexive-position($property, $value)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token atrule-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("@if")]),t._v(" $property !"),a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("=")]),t._v(" left and $property !"),a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("=")]),t._v(" right")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token atrule-line"}},[t._v("    "),a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("@error")]),t._v(' "Property #{$property} must be either left or right."')]),t._v("\n\n\n"),a("span",{pre:!0,attrs:{class:"token variable-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" if("),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" right, initial, "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$value")]),t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token variable-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" if("),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$property")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" right, "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$value")]),t._v(", initial)")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token property-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("left")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")])]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token property-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("right")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")])]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token selector"}},[t._v("[dir=rtl] &")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token property-line"}},[t._v("    "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("left")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$right-value")])]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token property-line"}},[t._v("    "),a("span",{pre:!0,attrs:{class:"token property"}},[t._v("right")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$left-value")])]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token selector"}},[t._v(".sidebar")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token atrule-line"}},[t._v("  "),a("span",{pre:!0,attrs:{class:"token atrule"}},[t._v("@include")]),t._v(" reflexive-position(top, 12px)")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")]),t._v("\n  "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// Error: Property top must be either left or right.")]),t._v("\n")])])])])],1),t._v(" "),a("p",[t._v("错误和堆栈跟踪的确切格式因实现而异，也可能取决于您的构建系统。这是在Dart Sass中命令行运行时的结果：")]),t._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[t._v('Error: "Property top must be either left or right."\n  ╷\n3 │     @error "Property #{$property} must be either left or right.";\n  │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  ╵\n  example.scss 3:5   reflexive-position()\n  example.scss 19:3  root stylesheet\n')])])])],1)},[],!1,null,null,null);s.default=e.exports}}]);