用路径'${this.id}'报错,直接后面+this.id就成功 求解${this.id}

在vue+mongoose+nodejs(express)项目

img
用这种没问题

img
用这种就报错
CastError: Cast to ObjectId failed for value "${this.id}" (type string) at path "_id" for model "Category"
messageFormat: undefined,
stringValue: '"${this.id}"',
kind: 'ObjectId',
value: '${this.id}',
path: '_id',
reason: Error: Argument passed in must be
a single String of 12 bytes or a string of 24 hex characters

他们说是模版字符串的问题,然后我去看了不知道怎么写,求解

模板字符串需要``符号包裹

用``包起来

('`categories/${this.id}`')