The answer to this question is it depends on what type of switch we are discussing. In the CCNA, router-on-a-stick is discussed on how to route traffic between VLANS. You can assign IP addresses to layer 2 switch for VLANs, but the layer 2 switch has no ability to move traffic between the broadcast domains. That's why you need a layer 3 device to sit between and move the traffic between the VLANS.
When talking about layer 3 switches, (which the CCNA material does not discuss) there is no need to have a router to move traffic between your VLANs because a layer 3/MLS has a routing engine built in, so you get the best of both worlds with a layer 3 switch. You assign the IP addresses to the SVIs and the layer 3 routing engine does the routing of the VLAN traffic. There's more details to it with packet rewrites and such, but there is no need to go into that much detail at the moment.